From cc05caf6a9b74af78d2f610c040b7c4c9814ba47 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Mon, 29 Apr 2013 05:33:56 +0800 Subject: [PATCH 01/31] Completely remove jQuery dependency from the core --- src/body.js | 20 +-- src/cell.js | 138 +++++++++------- src/extensions/filter/backgrid-filter.js | 28 ++-- .../moment-cell/backgrid-moment-cell.js | 4 +- .../paginator/backgrid-paginator.js | 18 +- .../select-all/backgrid-select-all.js | 32 ++-- .../select2-cell/backgrid-select2-cell.js | 6 +- .../text-cell/backgrid-text-cell.js | 2 + src/footer.js | 4 +- src/grid.js | 16 +- src/header.js | 27 +-- src/preamble.js | 147 +++++++++++++++++ src/row.js | 28 ++-- test/body.js | 62 +++---- test/cell.js | 154 +++++++++--------- test/extensions/filter.js | 76 ++++----- test/extensions/moment-cell.js | 4 +- test/extensions/paginator.js | 82 +++++----- test/extensions/select-all.js | 16 +- test/extensions/select2-cell.js | 20 +-- test/extensions/text-cell.js | 34 ++-- test/header.js | 48 +++--- test/row.js | 14 +- 23 files changed, 584 insertions(+), 396 deletions(-) diff --git a/src/body.js b/src/body.js index 094e3dd5..03e1391d 100644 --- a/src/body.js +++ b/src/body.js @@ -11,9 +11,9 @@ responsible for refreshing the rows after sorting, insertion and removal. @class Backgrid.Body - @extends Backbone.View + @extends Backgrid.View */ -var Body = Backgrid.Body = Backbone.View.extend({ +var Body = Backgrid.Body = Backgrid.View.extend({ /** @property */ tagName: "tbody", @@ -113,16 +113,16 @@ var Body = Backgrid.Body = Backbone.View.extend({ var index = collection.indexOf(model); this.rows.splice(index, 0, row); - var $el = this.$el; - var $children = $el.children(); - var $rowEl = row.render().$el; + var el = this.el; + var children = el.childNodes(); + var rowEl = row.render().el; if (options.render) { - if (index >= $children.length) { - $el.append($rowEl); + if (index >= children.length) { + el.appendChild(rowEl); } else { - $children.eq(index).before($rowEl); + el.insertBefore(rowEl, children[index]); } } }, @@ -201,7 +201,7 @@ var Body = Backgrid.Body = Backbone.View.extend({ row is rendered, otherwise no row is rendered. */ render: function () { - this.$el.empty(); + this.empty(); var fragment = document.createDocumentFragment(); for (var i = 0; i < this.rows.length; i++) { @@ -226,7 +226,7 @@ var Body = Backgrid.Body = Backbone.View.extend({ var row = this.rows[i]; row.remove.apply(row, arguments); } - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); }, /** diff --git a/src/cell.js b/src/cell.js index 06fb7177..b2c49198 100644 --- a/src/cell.js +++ b/src/cell.js @@ -12,9 +12,9 @@ @abstract @class Backgrid.CellEditor - @extends Backbone.View + @extends Backgrid.View */ -var CellEditor = Backgrid.CellEditor = Backbone.View.extend({ +var CellEditor = Backgrid.CellEditor = Backgrid.View.extend({ /** Initializer. @@ -45,7 +45,7 @@ var CellEditor = Backgrid.CellEditor = Backbone.View.extend({ */ postRender: function (model, column) { if (column == null || column.get("name") == this.column.get("name")) { - this.$el.focus(); + this.el.focus(); } return this; } @@ -90,7 +90,7 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ CellEditor.prototype.initialize.apply(this, arguments); if (options.placeholder) { - this.$el.attr("placeholder", options.placeholder); + this.el.setAttribute("placeholder", options.placeholder); } }, @@ -99,7 +99,7 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ exists. */ render: function () { - this.$el.val(this.formatter.fromRaw(this.model.get(this.column.get("name")))); + this.el.value = this.formatter.fromRaw(this.model.get(this.column.get("name"))); return this; }, @@ -135,7 +135,7 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ e.preventDefault(); e.stopPropagation(); - var val = this.$el.val(); + var val = this.el.value; var newValue = formatter.toRaw(val); if (_.isUndefined(newValue)) { model.trigger("backgrid:error", model, column, val); @@ -156,11 +156,18 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ postRender: function (model, column) { if (column == null || column.get("name") == this.column.get("name")) { // move the cursor to the end on firefox if text is right aligned - if (this.$el.css("text-align") === "right") { - var val = this.$el.val(); - this.$el.focus().val(null).val(val); + var el = this.el, textAlign; + if (window.getComputedStyle) { + textAlign = window.getComputedStyle(el).textAlign; } - else this.$el.focus(); + else if (el.currentStyle) textAlign = el.currentStyle.textAlign; + if (textAlign === "right") { + var val = el.value; + el.focus(); + el.val = null; + el.val = val; + } + else el.focus(); } return this; } @@ -177,9 +184,9 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ @abstract @class Backgrid.Cell - @extends Backbone.View + @extends Backgrid.View */ -var Cell = Backgrid.Cell = Backbone.View.extend({ +var Cell = Backgrid.Cell = Backgrid.View.extend({ /** @property */ tagName: "td", @@ -222,17 +229,28 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ this.formatter = Backgrid.resolveNameToClass(this.column.get("formatter") || this.formatter, "Formatter"); this.editor = Backgrid.resolveNameToClass(this.editor, "CellEditor"); this.listenTo(this.model, "change:" + this.column.get("name"), function () { - if (!this.$el.hasClass("editor")) this.render(); + if (!this.el.classList.contains("editor")) this.render(); }); }, + show: function () { + this.el.style.display = ''; + return this; + }, + + hide: function () { + this.el.style.display = "none"; + return this; + }, + /** Render a text string in a table cell. The text is converted from the model's raw value for this cell's column. */ render: function () { - this.$el.empty(); - this.$el.text(this.formatter.fromRaw(this.model.get(this.column.get("name")))); + this.empty(); + this.el.appendChild(window.document.createTextNode( + this.formatter.fromRaw(this.model.get(this.column.get("name"))))); this.delegateEvents(); return this; }, @@ -274,10 +292,10 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ // Need to redundantly undelegate events for Firefox this.undelegateEvents(); - this.$el.empty(); - this.$el.append(this.currentEditor.$el); + this.empty(); + this.el.appendChild(this.currentEditor.el); this.currentEditor.render(); - this.$el.addClass("editor"); + this.el.classList.add("editor"); model.trigger("backgrid:editing", model, column, this, this.currentEditor); } @@ -288,7 +306,7 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ */ renderError: function (model, column) { if (column == null || column.get("name") == this.column.get("name")) { - this.$el.addClass("error"); + this.el.classList.add("error"); } }, @@ -296,11 +314,11 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ Removes the editor and re-render in display mode. */ exitEditMode: function () { - this.$el.removeClass("error"); + this.el.classList.remove("error"); this.currentEditor.remove(); this.stopListening(this.currentEditor); delete this.currentEditor; - this.$el.removeClass("editor"); + this.el.classList.remove("editor"); this.render(); }, @@ -314,7 +332,7 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ this.currentEditor.remove.apply(this, arguments); delete this.currentEditor; } - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); } }); @@ -351,14 +369,16 @@ var UriCell = Backgrid.UriCell = Cell.extend({ className: "uri-cell", render: function () { - this.$el.empty(); + this.empty(); var formattedValue = this.formatter.fromRaw(this.model.get(this.column.get("name"))); - this.$el.append($("", { - tabIndex: -1, - href: formattedValue, - title: formattedValue, - target: "_blank" - }).text(formattedValue)); + var doc = window.document; + var a = doc.createElement("a"); + a.tabIndex = -1; + a.href = formattedValue; + a.title = formattedValue; + a.target = "_blank"; + a.appendChild(doc.createTextNode(formattedValue)); + this.el.appendChild(a); this.delegateEvents(); return this; } @@ -381,13 +401,15 @@ var EmailCell = Backgrid.EmailCell = StringCell.extend({ formatter: new EmailFormatter(), render: function () { - this.$el.empty(); + this.empty(); var formattedValue = this.formatter.fromRaw(this.model.get(this.column.get("name"))); - this.$el.append($("", { - tabIndex: -1, - href: "mailto:" + formattedValue, - title: formattedValue - }).text(formattedValue)); + var doc = window.document; + var a = doc.createElement("a"); + a.tabIndex = -1; + a.href = "mailto:" + formattedValue; + a.title = formattedValue; + a.appendChild(doc.createTextNode(formattedValue)); + this.el.appendChild(a); this.delegateEvents(); return this; } @@ -591,7 +613,7 @@ var BooleanCellEditor = Backgrid.BooleanCellEditor = CellEditor.extend({ */ render: function () { var val = this.formatter.fromRaw(this.model.get(this.column.get("name"))); - this.$el.prop("checked", val); + this.el.checked = val; return this; }, @@ -623,19 +645,19 @@ var BooleanCellEditor = Backgrid.BooleanCellEditor = CellEditor.extend({ model.trigger("backgrid:edited", model, column, command); } - var $el = this.$el; + var el = this.el; if (command.save() || command.moveLeft() || command.moveRight() || command.moveUp() || command.moveDown()) { e.preventDefault(); e.stopPropagation(); - var val = formatter.toRaw($el.prop("checked")); + var val = formatter.toRaw(el.checked); model.set(column.get("name"), val); model.trigger("backgrid:edited", model, column, command); } else if (e.type == "change") { - var val = formatter.toRaw($el.prop("checked")); + var val = formatter.toRaw(el.checked); model.set(column.get("name"), val); - $el.focus(); + el.focus(); } } @@ -666,12 +688,12 @@ var BooleanCell = Backgrid.BooleanCell = Cell.extend({ uncheck otherwise. */ render: function () { - this.$el.empty(); - this.$el.append($("", { - tabIndex: -1, - type: "checkbox", - checked: this.formatter.fromRaw(this.model.get(this.column.get("name"))) - })); + this.empty(); + var input = window.document.createElement("input"); + input.tabIndex = -1; + input.type = "checkbox"; + input.checked = this.formatter.fromRaw(this.model.get(this.column.get("name"))); + this.el.appendChild(input); this.delegateEvents(); return this; } @@ -723,7 +745,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ parameter. */ render: function () { - this.$el.empty(); + this.empty(); var optionValues = _.result(this, "optionValues"); var currentValue = this.model.get(this.column.get("name")); @@ -735,6 +757,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ var optionValue = null; var optgroupName = null; var optgroup = null; + var innerHTML = ''; for (var i = 0; i < optionValues.length; i++) { var optionValue = optionValues[i]; @@ -742,23 +765,24 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ optionText = optionValue[0]; optionValue = optionValue[1]; - this.$el.append(this.template({ + innerHTML += this.template({ text: optionText, value: optionValue, selected: optionValue == currentValue - })); + }); } else if (_.isObject(optionValue)) { optgroupName = optionValue.name; - optgroup = $("", { label: optgroupName }); - optgroup.append(this._renderOptions(optionValue.values, currentValue)); - this.$el.append(optgroup); + optgroup = this._renderOptions(optionValue.values, currentValue); + innerHTML = innerHTML + '' + optgroup + ''; } else { throw TypeError("optionValues elements must be a name-value pair or an object hash of { name: 'optgroup label', value: [option name-value pairs] }"); } } + this.el.innerHTML = innerHTML; + this.delegateEvents(); return this; @@ -771,7 +795,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ save: function (e) { var model = this.model; var column = this.column; - model.set(column.get("name"), this.formatter.toRaw(this.$el.val())); + model.set(column.get("name"), this.formatter.toRaw(this.el.value)); model.trigger("backgrid:edited", model, column, new Command(e)); }, @@ -865,14 +889,14 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ @throws {TypeError} If `optionValues` is malformed. */ render: function () { - this.$el.empty(); + this.empty(); var optionValues = this.optionValues; var rawData = this.formatter.fromRaw(this.model.get(this.column.get("name"))); try { if (!_.isArray(optionValues) || _.isEmpty(optionValues)) throw new TypeError; - + var doc = window.document; for (var i = 0; i < optionValues.length; i++) { var optionValue = optionValues[i]; @@ -881,7 +905,7 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ var optionValue = optionValue[1]; if (optionValue == rawData) { - this.$el.append(optionText); + this.el.appendChild(doc.createTextNode(optionText)); break; } } @@ -890,7 +914,7 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ for (var j = 0; j < optionGroupValues.length; j++) { var optionGroupValue = optionGroupValues[j]; if (optionGroupValue[1] == rawData) { - this.$el.append(optionGroupValue[0]); + this.el.appendChild(doc.createTextNode(optionGroupValue[0])); break; } } diff --git a/src/extensions/filter/backgrid-filter.js b/src/extensions/filter/backgrid-filter.js index c98c6658..ce935f85 100644 --- a/src/extensions/filter/backgrid-filter.js +++ b/src/extensions/filter/backgrid-filter.js @@ -6,7 +6,7 @@ Licensed under the MIT @license. */ -(function ($, _, Backbone, Backgrid, lunr) { +(function (_, Backbone, Backgrid, lunr) { "use strict"; @@ -16,7 +16,7 @@ @class Backgrid.Extension.ServerSideFilter */ - var ServerSideFilter = Backgrid.Extension.ServerSideFilter = Backbone.View.extend({ + var ServerSideFilter = Backgrid.Extension.ServerSideFilter = Backgrid.View.extend({ /** @property */ tagName: "form", @@ -47,11 +47,15 @@ */ initialize: function (options) { Backgrid.requireOptions(options, ["collection"]); - Backbone.View.prototype.initialize.apply(this, arguments); + Backgrid.View.prototype.initialize.apply(this, arguments); this.name = options.name || this.name; this.placeholder = options.placeholder || this.placeholder; }, + searchBox: function () { + return this.el.querySelector("input[type=text]"); + }, + /** Upon search form submission, this event handler constructs a query parameter object and pass it to Collection#fetch for server-side @@ -59,9 +63,9 @@ */ search: function (e) { if (e) e.preventDefault(); - var $text = $(e.target).find("input[type=text]"); + var searchBox = this.searchBox(); var data = {}; - data[$text.attr("name")] = $text.val(); + data[searchBox.name] = searchBox.value; this.collection.fetch({data: data}); }, @@ -71,7 +75,7 @@ */ clear: function (e) { if (e) e.preventDefault(); - this.$("input[type=text]").val(null); + this.searchBox().value = null; this.collection.fetch(); }, @@ -80,11 +84,11 @@ a preset value if supplied during initialization. */ render: function () { - this.$el.empty().append(this.template({ + this.empty().el.innerHTML = this.template({ name: this.name, placeholder: this.placeholder, value: this.value - })); + }); this.delegateEvents(); return this; } @@ -210,7 +214,7 @@ when all the matches have been found. */ search: function () { - var matcher = _.bind(this.makeMatcher(this.$("input[type=text]").val()), this); + var matcher = _.bind(this.makeMatcher(this.searchBox().value), this); this.collection.reset(this.shadowCollection.filter(matcher), {reindex: false}); }, @@ -218,7 +222,7 @@ Clears the search box and reset the collection to its original. */ clear: function () { - this.$("input[type=text]").val(null); + this.searchBox().value = null; this.collection.reset(this.shadowCollection.models, {reindex: false}); } @@ -343,7 +347,7 @@ query answer. */ search: function () { - var searchResults = this.index.search(this.$("input[type=text]").val()); + var searchResults = this.index.search(this.searchBox().value); var models = []; for (var i = 0; i < searchResults.length; i++) { var result = searchResults[i]; @@ -354,4 +358,4 @@ }); -}(jQuery, _, Backbone, Backgrid, lunr)); +}(_, Backbone, Backgrid, lunr)); diff --git a/src/extensions/moment-cell/backgrid-moment-cell.js b/src/extensions/moment-cell/backgrid-moment-cell.js index 0af94fa4..08bb0e13 100644 --- a/src/extensions/moment-cell/backgrid-moment-cell.js +++ b/src/extensions/moment-cell/backgrid-moment-cell.js @@ -5,7 +5,7 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function ($, _, Backbone, Backgrid, moment) { +(function (_, Backbone, Backgrid, moment) { /** MomentFormatter converts bi-directionally any datetime values in any format @@ -142,4 +142,4 @@ _.extend(MomentCell.prototype, MomentFormatter.prototype.defaults); -}(jQuery, _, Backbone, Backgrid, moment)); +}(_, Backbone, Backgrid, moment)); diff --git a/src/extensions/paginator/backgrid-paginator.js b/src/extensions/paginator/backgrid-paginator.js index 4c89b1ad..3a9f2e63 100644 --- a/src/extensions/paginator/backgrid-paginator.js +++ b/src/extensions/paginator/backgrid-paginator.js @@ -6,7 +6,7 @@ Licensed under the MIT @license. */ -(function ($, _, Backbone, Backgrid) { +(function (_, Backbone, Backgrid) { "use strict"; @@ -21,7 +21,7 @@ @class Backgrid.Extension.Paginator */ - Backgrid.Extension.Paginator = Backbone.View.extend({ + Backgrid.Extension.Paginator = Backgrid.View.extend({ /** @property */ className: "backgrid-paginator", @@ -91,8 +91,8 @@ */ changePage: function (e) { e.preventDefault(); - - var label = $(e.target).text(); + var target = e.target; + var label = target.textContent || target.innerText; var ffLabels = this.fastForwardHandleLabels; var collection = this.collection; @@ -115,7 +115,7 @@ } var state = collection.state; - var pageIndex = $(e.target).text() * 1; + var pageIndex = label * 1; collection.getPage(state.firstPage === 0 ? pageIndex - 1 : pageIndex); }, @@ -189,11 +189,11 @@ cell that spans all the columns. */ render: function () { - this.$el.empty(); + this.empty(); - this.$el.append(this.template({ + this.el.innerHTML = this.template({ handles: this.makeHandles() - })); + }); this.delegateEvents(); @@ -202,4 +202,4 @@ }); -}(jQuery, _, Backbone, Backgrid)); +}(_, Backbone, Backgrid)); diff --git a/src/extensions/select-all/backgrid-select-all.js b/src/extensions/select-all/backgrid-select-all.js index 2fd05eff..d90f3e23 100644 --- a/src/extensions/select-all/backgrid-select-all.js +++ b/src/extensions/select-all/backgrid-select-all.js @@ -5,15 +5,15 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function (window, $, _, Backbone, Backgrid) { +(function (_, Backbone, Backgrid) { /** Renders a checkbox for row selection. @class Backgrid.Extension.SelectRowCell - @extends Backbone.View + @extends Backgrid.View */ - var SelectRowCell = Backgrid.Extension.SelectRowCell = Backbone.View.extend({ + var SelectRowCell = Backgrid.Extension.SelectRowCell = Backgrid.View.extend({ /** @property */ className: "select-row-cell", @@ -23,9 +23,9 @@ /** @property */ events: { - "keydown :checkbox": "onKeydown", - "change :checkbox": "onChange", - "click :checkbox": "enterEditMode" + "keydown input[type=checkbox]": "onKeydown", + "change input[type=checkbox]": "onChange", + "click input[type=checkbox]": "enterEditMode" }, /** @@ -45,23 +45,27 @@ } this.listenTo(this.model, "backgrid:select", function (model, selected) { - this.$el.find(":checkbox").prop("checked", selected).change(); + this.checkbox().checked = selected; }); }, + checkbox: function () { + return this.el.querySelector("input[type=checkbox]"); + }, + /** Focuses the checkbox. */ enterEditMode: function () { - this.$el.find(":checkbox").focus(); + this.checkbox().focus(); }, /** Unfocuses the checkbox. */ exitEditMode: function () { - this.$el.find(":checkbox").blur(); + this.checkbox().blur(); }, /** @@ -72,7 +76,7 @@ if (command.passThru()) return true; // skip ahead to `change` if (command.cancel()) { e.stopPropagation(); - this.$el.find(":checkbox").blur(); + this.checkbox().blur(); } else if (command.save() || command.moveLeft() || command.moveRight() || command.moveUp() || command.moveDown()) { @@ -95,7 +99,7 @@ Renders a checkbox in a table cell. */ render: function () { - this.$el.empty().append(''); + this.empty().el.innerHTML = ''; this.delegateEvents(); return this; } @@ -148,7 +152,7 @@ if (selected) selectedModels[model.id || model.cid] = model; else { delete selectedModels[model.id || model.cid]; - this.$el.find(":checkbox").prop("checked", false); + this.checkbox().checked = false; } }); @@ -157,7 +161,7 @@ }); this.listenTo(collection, "backgrid:refresh", function () { - this.$el.find(":checkbox").prop("checked", false); + this.checkbox().checked = false; for (var i = 0; i < collection.length; i++) { var model = collection.at(i); if (selectedModels[model.id || model.cid]) { @@ -212,4 +216,4 @@ return result; }; -}(window, jQuery, _, Backbone, Backgrid)); +}(_, Backbone, Backgrid)); diff --git a/src/extensions/select2-cell/backgrid-select2-cell.js b/src/extensions/select2-cell/backgrid-select2-cell.js index d763ee88..8c8d4e5a 100644 --- a/src/extensions/select2-cell/backgrid-select2-cell.js +++ b/src/extensions/select2-cell/backgrid-select2-cell.js @@ -6,7 +6,7 @@ Licensed under the MIT @license. */ -(function (window, $, _, Backbone, Backgrid) { +(function (_, Backbone, Backgrid) { /** Select2CellEditor is a cell editor that renders a `select2` select box @@ -21,6 +21,8 @@ */ var Select2CellEditor = Backgrid.Extension.Select2CellEditor = Backgrid.SelectCellEditor.extend({ + use$: true, + /** @property */ events: { "close": "save", @@ -118,4 +120,4 @@ }); -}(window, jQuery, _, Backbone, Backgrid)); +}(_, Backbone, Backgrid)); diff --git a/src/extensions/text-cell/backgrid-text-cell.js b/src/extensions/text-cell/backgrid-text-cell.js index cdc4d575..4ad93fae 100644 --- a/src/extensions/text-cell/backgrid-text-cell.js +++ b/src/extensions/text-cell/backgrid-text-cell.js @@ -16,6 +16,8 @@ */ var TextareaEditor = Backgrid.Extension.TextareaEditor = Backgrid.CellEditor.extend({ + use$: true, + /** @property */ tagName: "div", diff --git a/src/footer.js b/src/footer.js index d9dbfc80..3594e317 100644 --- a/src/footer.js +++ b/src/footer.js @@ -12,9 +12,9 @@ @abstract @class Backgrid.Footer - @extends Backbone.View + @extends Backgrid.View */ -var Footer = Backgrid.Footer = Backbone.View.extend({ +var Footer = Backgrid.Footer = Backgrid.View.extend({ /** @property */ tagName: "tfoot", diff --git a/src/grid.js b/src/grid.js index 990192bb..bfcd74ad 100644 --- a/src/grid.js +++ b/src/grid.js @@ -12,7 +12,7 @@ By default, a Grid treats each model in a collection as a row, and each attribute in a model as a column. To render a grid you must provide a list of column metadata and a collection to the Grid constructor. Just like any - Backbone.View class, the grid is rendered as a DOM node fragment when you + Backgrid.View class, the grid is rendered as a DOM node fragment when you call render(). var grid = Backgrid.Grid({ @@ -43,7 +43,7 @@ Row class. @class Backgrid.Grid - @extends Backbone.View + @extends Backgrid.View See: @@ -53,7 +53,7 @@ - Backgrid.Row - Backgrid.Footer */ -var Grid = Backgrid.Grid = Backbone.View.extend({ +var Grid = Backgrid.Grid = Backgrid.View.extend({ /** @property */ tagName: "table", @@ -166,15 +166,15 @@ var Grid = Backgrid.Grid = Backbone.View.extend({ the it has successfully been rendered. */ render: function () { - this.$el.empty(); + this.empty(); - this.$el.append(this.header.render().$el); + this.el.appendChild(this.header.render().el); if (this.footer) { - this.$el.append(this.footer.render().$el); + this.el.appendChild(this.footer.render().el); } - this.$el.append(this.body.render().$el); + this.el.appendChild(this.body.render().el); this.delegateEvents(); @@ -192,7 +192,7 @@ var Grid = Backgrid.Grid = Backbone.View.extend({ this.header.remove.apply(this.header, arguments); this.body.remove.apply(this.body, arguments); this.footer && this.footer.remove.apply(this.footer, arguments); - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); } }); diff --git a/src/header.js b/src/header.js index bba95806..812b363f 100644 --- a/src/header.js +++ b/src/header.js @@ -12,9 +12,9 @@ refresh after sorting. @class Backgrid.HeaderCell - @extends Backbone.View + @extends Backgrid.View */ -var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ +var HeaderCell = Backgrid.HeaderCell = Backgrid.View.extend({ /** @property */ tagName: "th", @@ -57,8 +57,8 @@ var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ */ direction: function (dir) { if (arguments.length) { - if (this._direction) this.$el.removeClass(this._direction); - if (dir) this.$el.addClass(dir); + if (this._direction) this.el.classList.remove(this._direction); + if (dir) this.el.classList.add(dir); this._direction = dir; } @@ -192,9 +192,14 @@ var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ Renders a header cell with a sorter and a label. */ render: function () { - this.$el.empty(); - var $label = $("").text(this.column.get("label")).append(""); - this.$el.append($label); + this.empty(); + var doc = window.document; + var label = doc.createElement("a"); + label.appendChild(doc.createTextNode(this.column.get("label"))); + var caret = doc.createElement("b"); + caret.className = "sort-caret"; + label.appendChild(caret); + this.el.appendChild(label); this.delegateEvents(); return this; } @@ -243,9 +248,9 @@ var HeaderRow = Backgrid.HeaderRow = Backgrid.Row.extend({ single row of header cells. @class Backgrid.Header - @extends Backbone.View + @extends Backgrid.View */ -var Header = Backgrid.Header = Backbone.View.extend({ +var Header = Backgrid.Header = Backgrid.View.extend({ /** @property */ tagName: "thead", @@ -278,7 +283,7 @@ var Header = Backgrid.Header = Backbone.View.extend({ Renders this table head with a single row of header cells. */ render: function () { - this.$el.append(this.row.render().$el); + this.el.appendChild(this.row.render().el); this.delegateEvents(); return this; }, @@ -290,7 +295,7 @@ var Header = Backgrid.Header = Backbone.View.extend({ */ remove: function () { this.row.remove.apply(this.row, arguments); - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); } }); diff --git a/src/preamble.js b/src/preamble.js index 9ef888fa..dfd47af6 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -150,3 +150,150 @@ _.extend(Command.prototype, { } }); +var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; + +/** + @class Backgrid.View + @constructor + */ +var View = Backgrid.View = function(options) { + this.cid = _.uniqueId('view'); + this.options = options = options || {}; + _.extend(this, _.pick(options, viewOptions)); + this._ensureElement(options); + this.initialize.apply(this, arguments); + this.delegateEvents(); +}; + +var delegateEventSplitter = /^(\S+)\s*(.*)$/; + +_.extend(View.prototype, Backbone.Events, { + + use$: false, + + tagName: 'div', + + $: function(selector) { + return this.$el ? this.$el.find(selector) : this.el.querySelectorAll(selector); + }, + + initialize: function(){}, + + render: function() { + return this; + }, + + empty: function () { + if (this.$el) this.$el.remove(); + else { + var el = this.el; + while (el.hasChildNodes()) { + el.removeChild(el.firstChild); + } + } + return this; + }, + + remove: function() { + this.empty(); + this.stopListening(); + return this; + }, + + setElement: function(element, options) { + options = _.extend({use$: Backbone.$ && this.use$, delegate: true}, options || {}); + var delegate = options.delegate; + if (this.el) this.undelegateEvents(); + this.el = element; + if (options.use$) this.$el = Backbone.$(element); + if (delegate !== false) this.delegateEvents(); + return this; + }, + + _processEvents: function(events, func) { + for (var key in events) { + var method = events[key]; + if (!_.isFunction(method)) method = this[events[key]]; + if (!method) continue; + + method = _.bind(method, this); + var match = key.match(delegateEventSplitter); + func(match[1], match[2], method); + } + }, + + delegateEvents: function(events) { + if (!(events || (events = _.result(this, 'events')))) return this; + this.undelegateEvents(); + var el = this.el, $el = this.$el, cid = this.cid; + this._processEvents(events, function (eventName, selector, method) { + var namespacedEventName = eventName + '.delegateEvents' + cid; + if (selector === '') { + if ($el) $el.on(namespacedEventName, method); + else if (el.addEventListener) el.addEventListener(eventName, method); + else if (el.attachEvent) el.attachEvent('on' + eventName, method); + } else { + if ($el) $el.on(namespacedEventName, selector, method); + else { + var descendants = el.querySelectorAll(selector); + for (var i = 0, l = descendants.length; i < l; i++) { + var descendant = descendants[i]; + if (el.addEventListener) { + descendant.addEventListener(eventName, method); + } + else if (el.attachEvent) { + descendant.attachEvent('on' + eventName, method); + } + } + } + } + }); + return this; + }, + + undelegateEvents: function() { + var events = _.result(this, 'events'); + if (!events) return this; + if (this.$el) this.$el.off('.delegateEvents' + this.cid); + else { + var el = this.el; + this._processEvents(events, function (eventName, selector, method) { + if (selector === '') { + if (el.removeEventListener) el.removeEventListener(eventName, method); + if (el.detachEvent) el.detachEvent('on' + eventName, method); + } else { + var descendants = el.querySelectorAll(selector); + for (var i = 0, l = descendants.length; i < l; i++) { + var descendant = descendants[i]; + if (el.removeEventListener) { + descendant.removeEventListener(eventName, method); + } + else if (el.detachEvent) { + descendant.detachEvent('on' + eventName, method); + } + } + } + }); + } + return this; + }, + + _ensureElement: function(options) { + options = _.extend(options, {delegate: false}); + if (!this.el) { + var el = this.el = window.document.createElement(this.tagName); + var attrs = _.extend({}, _.result(this, 'attributes')); + if (this.id) attrs.id = _.result(this, 'id'); + if (this.className) attrs['class'] = _.result(this, 'className'); + for (var k in attrs) { + el.setAttribute(k, attrs[k]); + } + this.setElement(el, options); + } else { + this.setElement(_.result(this, 'el'), options); + } + } + +}); + +View.extend = Backbone.View.extend; diff --git a/src/row.js b/src/row.js index 7f57613f..87a588e6 100644 --- a/src/row.js +++ b/src/row.js @@ -12,9 +12,9 @@ rendered, and apply the appropriate cell to each attribute. @class Backgrid.Row - @extends Backbone.View + @extends Backgrid.View */ -var Row = Backgrid.Row = Backbone.View.extend({ +var Row = Backgrid.Row = Backgrid.View.extend({ /** @property */ tagName: "tr", @@ -48,7 +48,7 @@ var Row = Backgrid.Row = Backbone.View.extend({ for (var i = 0; i < cells.length; i++) { var cell = cells[i]; if (cell.column.get("name") == column.get("name")) { - if (renderable) cell.$el.show(); else cell.$el.hide(); + if (renderable) cell.show(); else cell.hide(); } } }); @@ -58,17 +58,17 @@ var Row = Backgrid.Row = Backbone.View.extend({ var cell = this.makeCell(column, options); cells.splice(i, 0, cell); - if (!cell.column.get("renderable")) cell.$el.hide(); + if (!cell.column.get("renderable")) cell.hide(); - var $el = this.$el; + var el = this.el, children = el.childNodes(); if (i === 0) { - $el.prepend(cell.render().$el); + el.insertBefore(cell.render().el, el.firstChild); } else if (i === columns.length - 1) { - $el.append(cell.render().$el); + el.appendChild(cell.render().el); } else { - $el.children().eq(i).before(cell.render().$el); + el.insertBefore(cell.render().el, children[i]); } }); @@ -100,14 +100,14 @@ var Row = Backgrid.Row = Backbone.View.extend({ Renders a row of cells for this row's model. */ render: function () { - this.$el.empty(); + this.empty(); var fragment = document.createDocumentFragment(); for (var i = 0; i < this.cells.length; i++) { var cell = this.cells[i]; fragment.appendChild(cell.render().el); - if (!cell.column.get("renderable")) cell.$el.hide(); + if (!cell.column.get("renderable")) cell.hide(); } this.el.appendChild(fragment); @@ -127,7 +127,7 @@ var Row = Backgrid.Row = Backbone.View.extend({ var cell = this.cells[i]; cell.remove.apply(cell, arguments); } - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); } }); @@ -137,9 +137,9 @@ var Row = Backgrid.Row = Backbone.View.extend({ row with a single column. @class Backgrid.EmptyRow - @extends Backbone.View + @extends Backgrid.View */ -var EmptyRow = Backgrid.EmptyRow = Backbone.View.extend({ +var EmptyRow = Backgrid.EmptyRow = Backgrid.View.extend({ /** @property */ tagName: "tr", @@ -165,7 +165,7 @@ var EmptyRow = Backgrid.EmptyRow = Backbone.View.extend({ Renders an empty row. */ render: function () { - this.$el.empty(); + this.empty(); var td = document.createElement("td"); td.setAttribute("colspan", this.columns.length); diff --git a/test/body.js b/test/body.js index a434d54c..a0f723f3 100644 --- a/test/body.js +++ b/test/body.js @@ -56,7 +56,7 @@ describe("A Body", function () { it("renders table rows using the given column definitions and collection", function () { expect(body.el.tagName).toBe("TBODY"); - var $trs = body.$el.children(); + var $trs = $(body.el).children(); expect($trs.length).toBe(3); expect(body.el.innerHTML).toBe('Alice\'s Adventures in Wonderland' + 'A Tale of Two Cities' + @@ -67,14 +67,14 @@ describe("A Body", function () { body.collection.add({ title: "The Great Gatsby" }); - var $trs = body.$el.children(); + var $trs = $(body.el).children(); expect($trs.length).toBe(4); expect($trs[3].outerHTML).toBe('The Great Gatsby'); body.collection.add({ title: "Les Misérables" }, {at: 1}); - $trs = body.$el.children(); + $trs = $(body.el).children(); expect($trs.length).toBe(5); expect($trs[1].outerHTML).toBe('Les Misérables'); }); @@ -96,14 +96,14 @@ describe("A Body", function () { title: "The Great Gatsby" }); - var $trs = body.$el.children(); + var $trs = $(body.el).children(); expect($trs.length).toBe(1); expect($trs[0].outerHTML).toBe('The Great Gatsby'); body.insertRow({ title: "Les Misérables" }, {at: 0}); - $trs = body.$el.children(); + $trs = $(body.el).children(); expect($trs.length).toBe(2); expect($trs[0].outerHTML).toBe('Les Misérables'); }); @@ -111,7 +111,7 @@ describe("A Body", function () { it("will remove a row from the DOM if a model is removed from its collection", function () { var twocities = body.collection.at(1); body.collection.remove(twocities); - var $trs = body.$el.children(); + var $trs = $(body.el).children(); expect($trs.length).toBe(2); expect(body.el.innerHTML).toBe('Alice\'s Adventures in Wonderland' + 'The Catcher in the Rye'); @@ -120,7 +120,7 @@ describe("A Body", function () { it("will remove a row from the DOM is removeRow is called directly with a model", function () { var twocities = body.collection.at(1); body.removeRow(twocities); - var $trs = body.$el.children(); + var $trs = $(body.el).children(); expect($trs.length).toBe(2); expect(body.el.innerHTML).toBe('Alice\'s Adventures in Wonderland' + 'The Catcher in the Rye'); @@ -137,7 +137,7 @@ describe("A Body", function () { }]); body.collection.off("backgrid:refresh", handler); expect(eventFired).toBe(true); - var $trs = body.$el.children(); + var $trs = $(body.el).children(); expect($trs.length).toBe(1); expect(body.el.innerHTML).toBe('Oliver Twist'); }); @@ -191,12 +191,12 @@ describe("A Body", function () { it("when adding to a full page", function () { col.add(new Backbone.Model({id: 4})); - expect(body.$el.find("tr").length).toBe(2); + expect($(body.el).find("tr").length).toBe(2); }); it("when removing from a full page", function () { col.remove(col.get(1)); - expect(body.$el.find("tr").length).toBe(2); + expect($(body.el).find("tr").length).toBe(2); }); }); @@ -212,11 +212,11 @@ describe("A Body", function () { }); body.render(); - expect(body.$el.find("tr.empty").length).toBe(0); + expect($(body.el).find("tr.empty").length).toBe(0); }); it("will not display the empty row if `options.emptyText` is not supplied", function () { - expect(body.$el.find("tr.empty").length).toBe(0); + expect($(body.el).find("tr.empty").length).toBe(0); books.reset(); body = new Backgrid.Body({ @@ -228,7 +228,7 @@ describe("A Body", function () { }); body.render(); - expect(body.$el.find("tr.empty").length).toBe(0); + expect($(body.el).find("tr.empty").length).toBe(0); }); it("will display the empty row if the collection is empty and `options.emptyText` is supplied", function () { @@ -243,8 +243,8 @@ describe("A Body", function () { }); body.render(); - expect(body.$el.find("tr.empty").length).toBe(1); - expect(body.$el.find("tr.empty > td").attr("colspan")).toBe("1"); + expect($(body.el).find("tr.empty").length).toBe(1); + expect($(body.el).find("tr.empty > td").attr("colspan")).toBe("1"); }); it("will clear the empty row if a new model is added to an empty collection", function () { @@ -258,16 +258,16 @@ describe("A Body", function () { collection: books }); body.render(); - expect(body.$el.find("tr.empty").length).toBe(1); + expect($(body.el).find("tr.empty").length).toBe(1); books.add({name: "Oliver Twist"}); - expect(body.$el.find("tr.empty").length).toBe(0); + expect($(body.el).find("tr.empty").length).toBe(0); books.reset(); - expect(body.$el.find("tr.empty").length).toBe(1); + expect($(body.el).find("tr.empty").length).toBe(1); body.insertRow({title: "The Catcher in the Rye"}); - expect(body.$el.find("tr.empty").length).toBe(0); + expect($(body.el).find("tr.empty").length).toBe(0); }); it("will put the next editable and renderable cell in edit mode when a save or one of the navigation commands is triggered via backgrid:edited from the collection", function () { @@ -297,34 +297,34 @@ describe("A Body", function () { // right people.trigger("backgrid:edited", people.at(0), columns.at(0), new Backgrid.Command({keyCode: 9})); - expect(body.rows[0].cells[0].$el.hasClass("editor")).toBe(false); - expect(body.rows[1].cells[0].$el.hasClass("editor")).toBe(true); + expect($(body.rows[0].cells[0].el).hasClass("editor")).toBe(false); + expect($(body.rows[1].cells[0].el).hasClass("editor")).toBe(true); // left people.trigger("backgrid:edited", people.at(1), columns.at(0), new Backgrid.Command({keyCode: 9, shiftKey: true})); - expect(body.rows[0].cells[0].$el.hasClass("editor")).toBe(true); - expect(body.rows[1].cells[0].$el.hasClass("editor")).toBe(false); + expect($(body.rows[0].cells[0].el).hasClass("editor")).toBe(true); + expect($(body.rows[1].cells[0].el).hasClass("editor")).toBe(false); // down people.trigger("backgrid:edited", people.at(0), columns.at(0), new Backgrid.Command({keyCode: 40})); - expect(body.rows[0].cells[0].$el.hasClass("editor")).toBe(false); - expect(body.rows[1].cells[0].$el.hasClass("editor")).toBe(true); + expect($(body.rows[0].cells[0].el).hasClass("editor")).toBe(false); + expect($(body.rows[1].cells[0].el).hasClass("editor")).toBe(true); // up people.trigger("backgrid:edited", people.at(1), columns.at(0), new Backgrid.Command({keyCode: 38})); - expect(body.rows[0].cells[0].$el.hasClass("editor")).toBe(true); - expect(body.rows[1].cells[0].$el.hasClass("editor")).toBe(false); + expect($(body.rows[0].cells[0].el).hasClass("editor")).toBe(true); + expect($(body.rows[1].cells[0].el).hasClass("editor")).toBe(false); // enter people.trigger("backgrid:edited", people.at(0), columns.at(0), new Backgrid.Command({keyCode: 13})); - expect(body.rows[0].cells[0].$el.hasClass("editor")).toBe(false); - expect(body.rows[1].cells[0].$el.hasClass("editor")).toBe(false); + expect($(body.rows[0].cells[0].el).hasClass("editor")).toBe(false); + expect($(body.rows[1].cells[0].el).hasClass("editor")).toBe(false); // esc body.rows[1].cells[0].enterEditMode(); people.trigger("backgrid:edited", people.at(1), columns.at(0), new Backgrid.Command({keyCode: 27})); - expect(body.rows[0].cells[0].$el.hasClass("editor")).toBe(false); - expect(body.rows[1].cells[0].$el.hasClass("editor")).toBe(false); + expect($(body.rows[0].cells[0].el).hasClass("editor")).toBe(false); + expect($(body.rows[1].cells[0].el).hasClass("editor")).toBe(false); }); }); diff --git a/test/cell.js b/test/cell.js index cbd7e677..dd07fdc2 100644 --- a/test/cell.js +++ b/test/cell.js @@ -121,15 +121,15 @@ describe("An InputCellEditor", function () { it("renders a text input box with a placeholder and the model value formatted for display", function () { editor.render(); expect(editor.el).toBeAnInstanceOf(HTMLInputElement); - expect(editor.$el.attr("placeholder")).toBe("put your text here"); - expect(editor.$el.val()).toBe("title"); + expect($(editor.el).attr("placeholder")).toBe("put your text here"); + expect($(editor.el).val()).toBe("title"); }); it("saves a formatted value in the input box to the model and triggers 'backgrid:edited' from the model when tab is pressed", function () { editor.render(); - editor.$el.val("another title"); + $(editor.el).val("another title"); var tab = $.Event("keydown", { keyCode: 9 }); - editor.$el.trigger(tab); + $(editor.el).trigger(tab); expect(editor.model.get(editor.column.get("name"))).toBe("another title"); expect(backgridEditedTriggerCount).toBe(1); expect(backgridEditedTriggerArgs[0]).toEqual(editor.model); @@ -139,9 +139,9 @@ describe("An InputCellEditor", function () { it("saves a formatted value in the input box to the model and triggers 'backgrid:edited' from the model when enter is pressed", function () { editor.render(); - editor.$el.val("another title"); + $(editor.el).val("another title"); var enter = $.Event("keydown", { keyCode: 13 }); - editor.$el.trigger(enter); + $(editor.el).trigger(enter); expect(editor.model.get(editor.column.get("name"))).toBe("another title"); expect(backgridEditedTriggerCount).toBe(1); expect(backgridEditedTriggerArgs[0]).toEqual(editor.model); @@ -157,9 +157,9 @@ describe("An InputCellEditor", function () { toRaw: jasmine.createSpy("toRaw").andReturn(undefined) }; editor.render(); - editor.$el.val("invalid value"); + $(editor.el).val("invalid value"); var enter = $.Event("keydown", { keyCode: 13 }); - editor.$el.trigger(enter); + $(editor.el).trigger(enter); expect(editor.formatter.toRaw.calls.length).toBe(1); expect(editor.formatter.toRaw).toHaveBeenCalledWith("invalid value"); expect(backgridErrorTriggerCount).toBe(1); @@ -168,7 +168,7 @@ describe("An InputCellEditor", function () { expect(backgridErrorTriggerArgs[2]).toEqual("invalid value"); editor.formatter.toRaw.reset(); - editor.$el.blur(); + $(editor.el).blur(); expect(backgridErrorTriggerCount).toBe(2); expect(backgridErrorTriggerArgs[0]).toEqual(editor.model); expect(backgridErrorTriggerArgs[1]).toEqual(editor.column); @@ -177,9 +177,9 @@ describe("An InputCellEditor", function () { it("discards changes and triggers 'backgrid:edited' from the model when esc is pressed'", function () { editor.render(); - editor.$el.val("new value"); + $(editor.el).val("new value"); var esc = $.Event("keydown", { keyCode: 27 }); - editor.$el.trigger(esc); + $(editor.el).trigger(esc); expect(backgridEditedTriggerCount).toBe(1); expect(backgridEditedTriggerArgs[0]).toEqual(editor.model); expect(backgridEditedTriggerArgs[1]).toEqual(editor.column); @@ -189,7 +189,7 @@ describe("An InputCellEditor", function () { it("triggers 'backgrid:edited' from the model when value hasn't changed and focus is lost", function () { editor.render(); - editor.$el.blur(); + $(editor.el).blur(); expect(backgridEditedTriggerCount).toBe(1); expect(backgridEditedTriggerArgs[0]).toEqual(editor.model); expect(backgridEditedTriggerArgs[1]).toEqual(editor.column); @@ -199,8 +199,8 @@ describe("An InputCellEditor", function () { it("saves the value if the value is valid when going out of focus", function () { editor.render(); - editor.$el.val("another title"); - editor.$el.blur(); + $(editor.el).val("another title"); + $(editor.el).blur(); expect(backgridEditedTriggerCount).toBe(1); expect(backgridEditedTriggerArgs[0]).toEqual(editor.model); expect(backgridEditedTriggerArgs[1]).toEqual(editor.column); @@ -284,28 +284,28 @@ describe("A Cell", function () { it("renders a td with the model value formatted for display", function () { cell.render(); - expect(cell.$el.text()).toBe("title"); + expect($(cell.el).text()).toBe("title"); }); it("goes into edit mode on click", function () { cell.render(); - cell.$el.click(); - expect(cell.$el.hasClass("editor")).toBe(true); + $(cell.el).click(); + expect($(cell.el).hasClass("editor")).toBe(true); }); it("goes into edit mode when `enterEditMode` is called", function () { cell.render(); cell.enterEditMode(); - expect(cell.$el.hasClass("editor")).toBe(true); + expect($(cell.el).hasClass("editor")).toBe(true); }); it("goes back into display mode when `exitEditMode` is called", function () { cell.render(); - cell.$el.click(); + $(cell.el).click(); cell.exitEditMode(); - expect(cell.$el.hasClass("editor")).toBe(false); - expect(cell.$el.text()).toBe("title"); + expect($(cell.el).hasClass("editor")).toBe(false); + expect($(cell.el).text()).toBe("title"); }); it("renders error when the editor triggers 'backgrid:error'", function () { @@ -316,36 +316,36 @@ describe("A Cell", function () { }; cell.render(); - cell.$el.click(); + $(cell.el).click(); var editor = cell.currentEditor; - editor.$el.val(undefined); + $(editor.el).val(undefined); var enter = $.Event("keydown", { keyCode: 13 }); - editor.$el.trigger(enter); + $(editor.el).trigger(enter); - expect(cell.$el.hasClass("error")).toBe(true); - expect(cell.$el.hasClass("editor")).toBe(true); + expect($(cell.el).hasClass("error")).toBe(true); + expect($(cell.el).hasClass("editor")).toBe(true); }); describe("when the model value has changed", function () { it("refreshes during display mode", function () { cell.render(); book.set("title", "another title"); - expect(cell.$el.text()).toBe("another title"); + expect($(cell.el).text()).toBe("another title"); }); it("does not refresh during display mode if the change was silenced", function () { cell.render(); book.set("title", "another title", {silent: true}); - expect(cell.$el.text()).toBe("title"); + expect($(cell.el).text()).toBe("title"); }); it("does not refresh during edit mode", function () { cell.render(); - cell.$el.click(); + $(cell.el).click(); book.set("title", "another title"); - expect(cell.$el.find("input[type=text]").val(), "title"); + expect($(cell.el).find("input[type=text]").val(), "title"); }); }); @@ -369,7 +369,7 @@ describe("A StringCell", function () { }); cell.render(); - expect(cell.$el.hasClass("string-cell")).toBe(true); + expect($(cell.el).hasClass("string-cell")).toBe(true); }); }); @@ -398,13 +398,13 @@ describe("A UriCell", function () { it("applies a uri-cell class to the cell", function () { cell.render(); - expect(cell.$el.hasClass("uri-cell")).toBe(true); + expect($(cell.el).hasClass("uri-cell")).toBe(true); }); it("renders the model value in an anchor", function () { cell.render(); - expect(cell.$el.find("a").attr("href")).toBe("http://www.example.com"); - expect(cell.$el.find("a").text()).toBe("http://www.example.com"); + expect($(cell.el).find("a").attr("href")).toBe("http://www.example.com"); + expect($(cell.el).find("a").text()).toBe("http://www.example.com"); }); }); @@ -437,8 +437,8 @@ describe("An EmailCell", function () { it("renders the model value in a mailto: anchor", function () { cell.render(); - expect(cell.$el.find("a").attr("href")).toBe("mailto:email@host"); - expect(cell.$el.find("a").text()).toBe("email@host"); + expect($(cell.el).find("a").attr("href")).toBe("mailto:email@host"); + expect($(cell.el).find("a").text()).toBe("email@host"); }); }); @@ -456,7 +456,7 @@ describe("A NumberCell", function () { } }); cell.render(); - expect(cell.$el.hasClass("number-cell")).toBe(true); + expect($(cell.el).hasClass("number-cell")).toBe(true); }); }); @@ -474,7 +474,7 @@ describe("An IntegerCell", function () { } }); cell.render(); - expect(cell.$el.hasClass("integer-cell")).toBe(true); + expect($(cell.el).hasClass("integer-cell")).toBe(true); }); }); @@ -504,7 +504,7 @@ describe("A DatetimeCell", function () { it("applies a datetime-cell class to the cell", function () { cell.render(); - expect(cell.$el.hasClass("datetime-cell")).toBe(true); + expect($(cell.el).hasClass("datetime-cell")).toBe(true); }); it("renders a placeholder for different datetime formats for the editor according to configuration", function () { @@ -555,7 +555,7 @@ describe("A DatetimeCell", function () { model: new Backbone.Model({ datetime: null }), column: column }); - expect(cell.$el.html()).toBe(''); + expect($(cell.el).html()).toBe(''); }); }); @@ -573,7 +573,7 @@ describe("A DateCell", function () { } }); cell.render(); - expect(cell.$el.hasClass("date-cell")).toBe(true); + expect($(cell.el).hasClass("date-cell")).toBe(true); }); }); @@ -590,7 +590,7 @@ describe("A TimeCell", function () { } }); cell.render(); - expect(cell.$el.hasClass("time-cell")).toBe(true); + expect($(cell.el).hasClass("time-cell")).toBe(true); }); }); @@ -620,32 +620,32 @@ describe("A BooleanCell", function () { it("has a display mode that renders a checkbox with the checkbox checked if the model value is true, not checked otherwise", function () { cell.render(); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(true); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(true); model.set("ate", false); cell.render(); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(false); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(false); }); it("goes into edit mode after clicking the cell with the checkbox intact", function () { cell.render(); - cell.$el.click(); - expect(cell.$el.hasClass("editor")).toBe(true); - expect(cell.$el.find(":checkbox").length).toBe(1); + $(cell.el).click(); + expect($(cell.el).hasClass("editor")).toBe(true); + expect($(cell.el).find(":checkbox").length).toBe(1); }); it("goes into edit mode after calling `enterEditMode` with the checkbox intact", function () { cell.render(); cell.enterEditMode(); - expect(cell.$el.hasClass("editor")).toBe(true); - expect(cell.$el.find(":checkbox").length).toBe(1); + expect($(cell.el).hasClass("editor")).toBe(true); + expect($(cell.el).find(":checkbox").length).toBe(1); }); it("goes back to display mode after calling `exitEditMode`", function () { cell.render(); cell.enterEditMode(); cell.exitEditMode(); - expect(cell.$el.hasClass("editor")).toBe(false); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(true); + expect($(cell.el).hasClass("editor")).toBe(false); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(true); }); it("triggers `backgrid:edited` when the checkbox goes out of focus", function () { @@ -657,25 +657,25 @@ describe("A BooleanCell", function () { }); cell.render(); - cell.$el.click(); - cell.$el.find(":checkbox").blur(); + $(cell.el).click(); + $(cell.el).find(":checkbox").blur(); expect(backgridEditedTriggerCount).toBe(1); expect(backgridEditedTriggerArgs[0]).toBe(cell.model); expect(backgridEditedTriggerArgs[1]).toBe(cell.column); expect(backgridEditedTriggerArgs[2].passThru()).toBe(true); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(true); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(true); cell.render(); - cell.$el.click(); - cell.currentEditor.$el.mousedown(); - cell.$el.find(":checkbox").blur(); + $(cell.el).click(); + cell.current$(editor.el).mousedown(); + $(cell.el).find(":checkbox").blur(); expect(backgridEditedTriggerCount).toBe(1); }); it("saves a boolean value to the model when the checkbox is toggled", function () { cell.render(); cell.enterEditMode(); - cell.$el.find(":checkbox").prop("checked", false).change(); + $(cell.el).find(":checkbox").prop("checked", false).change(); expect(cell.model.get(cell.column.get("name"))).toBe(false); }); @@ -683,25 +683,25 @@ describe("A BooleanCell", function () { it("refreshes during display mode", function () { cell.render(); model.set("ate", false); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(false); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(false); model.set("ate", true); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(true); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(true); }); it("does not refresh during display mode if the change was silenced", function () { cell.render(); model.set("ate", false, {silent: true}); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(true); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(true); model.set("ate", false); model.set("ate", true, {silent: true}); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(true); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(true); }); it("does not refresh during edit mode", function () { cell.render(); - cell.$el.click(); + $(cell.el).click(); model.set("ate", false); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(true); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(true); }); }); @@ -751,7 +751,7 @@ describe("A SelectCellEditor", function () { editor.setOptionValues(optionValues); editor.render(); expect(editor.el.tagName).toBe("SELECT"); - var $options = editor.$el.children(); + var $options = $(editor.el).children(); expect($options.length).toBe(2); expect($options.eq(0).val()).toBe("1"); expect($options.eq(0).prop("selected")).toBe(false); @@ -779,7 +779,7 @@ describe("A SelectCellEditor", function () { }); editor.render(); expect(editor.el.tagName).toBe("SELECT"); - var $options = editor.$el.children(); + var $options = $(editor.el).children(); expect($options.length).toBe(2); expect($options.eq(0).val()).toBe("1"); expect($options.eq(0).prop("selected")).toBe(false); @@ -804,7 +804,7 @@ describe("A SelectCellEditor", function () { editor.setOptionValues(optionGroupValues); editor.render(); - var $optionGroups = editor.$el.children(); + var $optionGroups = $(editor.el).children(); expect($optionGroups.length).toBe(2); var $group1 = $optionGroups.eq(0); @@ -853,7 +853,7 @@ describe("A SelectCellEditor", function () { return optionGroupValues; }); editor.render(); - var $optionGroups = editor.$el.children(); + var $optionGroups = $(editor.el).children(); expect($optionGroups.length).toBe(2); var $group1 = $optionGroups.eq(0); @@ -911,7 +911,7 @@ describe("A SelectCellEditor", function () { backgridEditedTriggerArgs = [].slice.call(arguments); }); - editor.$el.val(1).change(); + $(editor.el).val(1).change(); expect(editor.formatter.toRaw).toHaveBeenCalledWith("1"); expect(editor.formatter.toRaw.calls.length).toBe(1); expect(editor.model.get(editor.column.get("name"))).toBe("1"); @@ -982,7 +982,7 @@ describe("A SelectCell", function () { cell.render(); - expect(cell.$el.hasClass("select-cell")).toBe(true); + expect($(cell.el).hasClass("select-cell")).toBe(true); }); it("renders the label of the selected option in display mode", function () { @@ -999,7 +999,7 @@ describe("A SelectCell", function () { }); cell.render(); - expect(cell.$el.text()).toBe("Girl"); + expect($(cell.el).text()).toBe("Girl"); var cell = new (Backgrid.SelectCell.extend({ optionValues: optionGroupValues @@ -1014,7 +1014,7 @@ describe("A SelectCell", function () { }); cell.render(); - expect(cell.$el.text()).toBe("Banana"); + expect($(cell.el).text()).toBe("Banana"); }); it("throws TypeError when rendering a malformed option value list", function () { @@ -1066,21 +1066,21 @@ describe("A SelectCell", function () { it("refreshes during display mode", function () { cell.render(); model.set("gender", 1); - expect(cell.$el.text()).toBe("Boy"); + expect($(cell.el).text()).toBe("Boy"); }); it("does not refresh during display mode if the change was silenced", function () { cell.render(); model.set("gender", 1, {silent: true}); - expect(cell.$el.text()).toBe("Girl"); + expect($(cell.el).text()).toBe("Girl"); }); it("does not refresh during edit mode", function () { cell.render(); - cell.$el.click(); + $(cell.el).click(); model.set("gender", 1); - expect(cell.$el.find("option[selected]").val()).toBe("2"); - expect(cell.$el.find("option[selected]").text()).toBe("Girl"); + expect($(cell.el).find("option[selected]").val()).toBe("2"); + expect($(cell.el).find("option[selected]").text()).toBe("Girl"); }); }); diff --git a/test/extensions/filter.js b/test/extensions/filter.js index e4dc3aa9..6456c9df 100644 --- a/test/extensions/filter.js +++ b/test/extensions/filter.js @@ -28,29 +28,29 @@ describe("A ServerSideFilter", function () { placeholder: "placeholder" }); filter.render(); - expect(filter.$el.find(":text").attr("name")).toBe("name"); - expect(filter.$el.find(":text").attr("placeholder")).toBe("placeholder"); + expect($(filter.el).find(":text").attr("name")).toBe("name"); + expect($(filter.el).find(":text").attr("placeholder")).toBe("placeholder"); var filter = new Backgrid.Extension.ServerSideFilter({ collection: collection, name: "name" }); filter.render(); - expect(filter.$el.find(":text").attr("placeholder")).toBeUndefined(); - expect(filter.$el.find(":text").attr("name")).toBe("name"); + expect($(filter.el).find(":text").attr("placeholder")).toBeUndefined(); + expect($(filter.el).find(":text").attr("name")).toBe("name"); var filter = new Backgrid.Extension.ServerSideFilter({ collection: collection, placeholder: "placeholder" }); filter.render(); - expect(filter.$el.find(":text").attr("placeholder")).toBe("placeholder"); + expect($(filter.el).find(":text").attr("placeholder")).toBe("placeholder"); var filter = new Backgrid.Extension.ServerSideFilter({ collection: collection }); filter.render(); - expect(filter.$el.find(":text").attr("placeholder")).toBeUndefined(); + expect($(filter.el).find(":text").attr("placeholder")).toBeUndefined(); }); it("can fetch with a query on submit", function () { @@ -64,8 +64,8 @@ describe("A ServerSideFilter", function () { collection: collection }); filter.render(); - filter.$el.find(":text").val("query"); - filter.$el.submit(); + $(filter.el).find(":text").val("query"); + $(filter.el).submit(); expect(url).toBe("http://www.example.com"); expect(data).toEqual({q: "query"}); expect(collection.length).toBe(1); @@ -78,9 +78,9 @@ describe("A ServerSideFilter", function () { collection: collection }); filter.render(); - filter.$el.find(":text").val("query"); - filter.$el.find(".close").click(); - expect(filter.$el.find(":text").val()).toBe(""); + $(filter.el).find(":text").val("query"); + $(filter.el).find(".close").click(); + expect($(filter.el).find(":text").val()).toBe(""); collection.fetch.reset(); }); @@ -114,7 +114,7 @@ describe("A ClientSideFilter", function () { }); runs(function () { - filter.$el.find(":text").val("bob").change(); + $(filter.el).find(":text").val("bob").change(); }); waitsFor(function () { return collection.length === 1; @@ -124,7 +124,7 @@ describe("A ClientSideFilter", function () { }); runs(function () { - filter.$el.find(".close").click(); + $(filter.el).find(".close").click(); }); waitsFor(function () { return collection.length === 3; @@ -136,8 +136,8 @@ describe("A ClientSideFilter", function () { }); runs(function () { - filter.$el.find(":text").val("ALICE"); - filter.$el.submit(); + $(filter.el).find(":text").val("ALICE"); + $(filter.el).submit(); }); waitsFor(function () { return collection.length === 1; @@ -147,7 +147,7 @@ describe("A ClientSideFilter", function () { }); runs(function () { - filter.$el.find(":text").val("al").keyup(); + $(filter.el).find(":text").val("al").keyup(); }); waitsFor(function () { return collection.length === 2; @@ -158,7 +158,7 @@ describe("A ClientSideFilter", function () { }); runs(function () { - filter.$el.find(":text").val("alic bob").keyup(); + $(filter.el).find(":text").val("alic bob").keyup(); }); waitsFor(function () { return collection.length === 3; @@ -180,7 +180,7 @@ describe("A ClientSideFilter", function () { }); filter.render(); collection.add({id: 4, name: "doug"}); - filter.$el.find(":text").val("doug").change(); + $(filter.el).find(":text").val("doug").change(); }); waitsFor(function () { return collection.length === 1; @@ -201,7 +201,7 @@ describe("A ClientSideFilter", function () { }); filter.render(); collection.remove(collection.at(0)); - filter.$el.find(":text").val("alice").change(); + $(filter.el).find(":text").val("alice").change(); }); waitsFor(function () { return collection.length === 0; @@ -224,7 +224,7 @@ describe("A ClientSideFilter", function () { }); filter.render(); filter.collection.at(0).set("name", "charlie"); - filter.$el.find(":text").val("charlie").change(); + $(filter.el).find(":text").val("charlie").change(); }); waitsFor(function () { return collection.length === 1; @@ -247,7 +247,7 @@ describe("A ClientSideFilter", function () { }); filter.render(); filter.collection.reset([{id: 4, name: "charlie"}, {id: 5, name: "doug"}]); - filter.$el.find(":text").val("").change(); + $(filter.el).find(":text").val("").change(); }); waitsFor(function () { return collection.length === 2; @@ -293,7 +293,7 @@ describe("A LunrFilter", function () { }); runs(function () { - filter.$el.find(":text").val("crap").change(); + $(filter.el).find(":text").val("crap").change(); }); waitsFor(function () { return collection.length === 1; @@ -303,7 +303,7 @@ describe("A LunrFilter", function () { }); runs(function () { - filter.$el.find(".close").click(); + $(filter.el).find(".close").click(); }); waitsFor(function () { return collection.length === 2; @@ -314,8 +314,8 @@ describe("A LunrFilter", function () { }); runs(function () { - filter.$el.find(":text").val("alice"); - filter.$el.submit(); + $(filter.el).find(":text").val("alice"); + $(filter.el).submit(); }); waitsFor(function () { return collection.length === 1; @@ -325,7 +325,7 @@ describe("A LunrFilter", function () { }); runs(function () { - filter.$el.find(":text").val("fat").keyup(); + $(filter.el).find(":text").val("fat").keyup(); }); waitsFor(function () { return collection.length === 2; @@ -353,21 +353,21 @@ describe("A LunrFilter", function () { }); runs(function () { - filter.$el.find(":text").val("crap").change(); + $(filter.el).find(":text").val("crap").change(); }); waitsFor(function () { return collection.length === 0; }, "collection.length to become 0", 500); runs(function () { - filter.$el.find(":text").val("alice").change(); + $(filter.el).find(":text").val("alice").change(); }); waitsFor(function () { return collection.length === 0; }, "collection.length to become 0", 500); runs(function () { - filter.$el.find(":text").val("charlie").change(); + $(filter.el).find(":text").val("charlie").change(); }); waitsFor(function () { return collection.length === 1; @@ -377,7 +377,7 @@ describe("A LunrFilter", function () { }); runs(function () { - filter.$el.find(":text").val("doug").change(); + $(filter.el).find(":text").val("doug").change(); }); waitsFor(function () { return collection.length === 1 && collection.at(0).id === 4; @@ -396,7 +396,7 @@ describe("A LunrFilter", function () { }); runs(function () { - filter.$el.find(":text").val("charlie").change(); + $(filter.el).find(":text").val("charlie").change(); }); waitsFor(function () { return collection.length === 1; @@ -418,14 +418,14 @@ describe("A LunrFilter", function () { }); runs(function () { - filter.$el.find(":text").val("bob").change(); + $(filter.el).find(":text").val("bob").change(); }); waitsFor(function () { return collection.length === 0; }, "collection.length to become 0", 500); runs(function () { - filter.$el.find(":text").val("alice").change(); + $(filter.el).find(":text").val("alice").change(); }); waitsFor(function () { return collection.length === 1; @@ -448,14 +448,14 @@ describe("A LunrFilter", function () { }); runs(function () { - filter.$el.find(":text").val("alice").change(); + $(filter.el).find(":text").val("alice").change(); }); waitsFor(function () { return collection.length === 0; }, "collection.length to become 0", 500); runs(function () { - filter.$el.find(":text").val("charlie").change(); + $(filter.el).find(":text").val("charlie").change(); }); waitsFor(function () { return collection.length === 1; @@ -478,20 +478,20 @@ describe("A LunrFilter", function () { }); runs(function() { - filter.$el.find(":text").val("crap").change(); + $(filter.el).find(":text").val("crap").change(); }); waitsFor(function () { return collection.length === 1; }, "collection.length to become 1", 500); runs(function () { - filter.$el.find(".close").click(); + $(filter.el).find(".close").click(); }); waitsFor(function () { return collection.length === 2; }, "collection.length to become 2", 500); runs(function () { - expect(filter.$el.find(":text").val()).toBe(''); + expect($(filter.el).find(":text").val()).toBe(''); expect(collection.at(0).id).toBe(1); expect(collection.at(1).id).toBe(2); }); diff --git a/test/extensions/moment-cell.js b/test/extensions/moment-cell.js index 84373ff6..47d36913 100644 --- a/test/extensions/moment-cell.js +++ b/test/extensions/moment-cell.js @@ -197,13 +197,13 @@ describe("A MomentCell", function () { }); it("applies a moment-cell class to the cell", function () { - expect(cell.render().$el.hasClass("moment-cell")).toBe(true); + expect($(cell.render().el).hasClass("moment-cell")).toBe(true); }); it("renders a placeholder for the input format for the editor", function () { cell.render(); cell.$el.click(); - expect(cell.currentEditor.$el.attr("placeholder")).toBe(Backgrid.Extension.MomentFormatter.prototype.defaults.displayFormat); + expect($(cell.currentEditor.el).attr("placeholder")).toBe(Backgrid.Extension.MomentFormatter.prototype.defaults.displayFormat); }); }); diff --git a/test/extensions/paginator.js b/test/extensions/paginator.js index 0b4348ac..741b13ba 100644 --- a/test/extensions/paginator.js +++ b/test/extensions/paginator.js @@ -36,20 +36,20 @@ describe("A Paginator", function () { }); it("has page handles that go to the correct pages when clicked", function () { - paginator.$el.find("a").eq("3").click(); + $(paginator.el).find("a").eq("3").click(); expect(books.state.currentPage).toBe(2); - paginator.$el.find("a").eq("2").click(); + $(paginator.el).find("a").eq("2").click(); expect(books.state.currentPage).toBe(1); paginator.windowSize = 1; paginator.render(); - paginator.$el.find("a").eq(4).click(); - expect(paginator.$el.find("a").eq(2).html()).toBe('3'); + $(paginator.el).find("a").eq(4).click(); + expect($(paginator.el).find("a").eq(2).html()).toBe('3'); expect(books.state.currentPage).toBe(3); - paginator.$el.find("a").eq(1).click(); - expect(paginator.$el.find("a").eq(2).html()).toBe('2'); + $(paginator.el).find("a").eq(1).click(); + expect($(paginator.el).find("a").eq(2).html()).toBe('2'); expect(books.state.currentPage).toBe(2); books = new Books([{ @@ -71,19 +71,19 @@ describe("A Paginator", function () { paginator.render(); - paginator.$el.find("a").eq("3").click(); + $(paginator.el).find("a").eq("3").click(); expect(books.state.currentPage).toBe(1); - paginator.$el.find("a").eq("2").click(); + $(paginator.el).find("a").eq("2").click(); expect(books.state.currentPage).toBe(0); }); it("renders page handles <= windowSize", function () { - expect(paginator.$el.find("a").length).toBe(7); + expect($(paginator.el).find("a").length).toBe(7); paginator.windowSize = 1; paginator.render(); - expect(paginator.$el.find("a").length).toBe(5); + expect($(paginator.el).find("a").length).toBe(5); }); it("displays a single page handler number 1 when the collection is empty", function () { @@ -94,28 +94,28 @@ describe("A Paginator", function () { paginator.render(); - expect(paginator.$el.find("a").length).toBe(5); - expect(paginator.$el.find("a[title='No. 1']").length).toBe(1); - expect(paginator.$el.find("a[title='No. 2']").length).toBe(0); + expect($(paginator.el).find("a").length).toBe(5); + expect($(paginator.el).find("a[title='No. 1']").length).toBe(1); + expect($(paginator.el).find("a[title='No. 2']").length).toBe(0); }); it("refreshes upon row insertion", function () { books.add({title: "Lord of the Rings"}); - expect(paginator.$el.find("a").length).toBe(8); - expect(paginator.$el.find("a[title='No. 4']").length).toBe(1); + expect($(paginator.el).find("a").length).toBe(8); + expect($(paginator.el).find("a[title='No. 4']").length).toBe(1); }); it("refreshes upon row removal", function () { books.remove(books.first()); - expect(paginator.$el.find("a").length).toBe(6); - expect(paginator.$el.find("a[title='No. 3']").length).toBe(0); + expect($(paginator.el).find("a").length).toBe(6); + expect($(paginator.el).find("a[title='No. 3']").length).toBe(0); }); it("refreshes upon collection reset", function () { books.fullCollection.reset(); - expect(paginator.$el.find("a").length).toBe(5); - expect(paginator.$el.find("a[title='No. 1']").length).toBe(1); - expect(paginator.$el.find("a[title='No. 2']").length).toBe(0); + expect($(paginator.el).find("a").length).toBe(5); + expect($(paginator.el).find("a[title='No. 1']").length).toBe(1); + expect($(paginator.el).find("a[title='No. 2']").length).toBe(0); }); }); @@ -152,12 +152,12 @@ describe("A Paginator", function () { }]); }; - paginator.$el.find("a").eq(4).click(); - expect(paginator.$el.find("a").eq(2).html()).toBe('3'); + $(paginator.el).find("a").eq(4).click(); + expect($(paginator.el).find("a").eq(2).html()).toBe('3'); expect(books.state.currentPage).toBe(3); - paginator.$el.find("a").eq(1).click(); - expect(paginator.$el.find("a").eq(2).html()).toBe('2'); + $(paginator.el).find("a").eq(1).click(); + expect($(paginator.el).find("a").eq(2).html()).toBe('2'); expect(books.state.currentPage).toBe(2); books = new Books([{ @@ -178,21 +178,21 @@ describe("A Paginator", function () { paginator.render(); - paginator.$el.find("a").eq("3").click(); + $(paginator.el).find("a").eq("3").click(); expect(books.state.currentPage).toBe(1); - paginator.$el.find("a").eq("2").click(); + $(paginator.el).find("a").eq("2").click(); expect(books.state.currentPage).toBe(0); Backbone.ajax = oldAjax; }); it("renders page handles <= windowSize", function () { - expect(paginator.$el.find("a").length).toBe(7); + expect($(paginator.el).find("a").length).toBe(7); paginator.windowSize = 1; paginator.render(); - expect(paginator.$el.find("a").length).toBe(5); + expect($(paginator.el).find("a").length).toBe(5); }); it("displays a single page handler number 1 when the collection is empty and totalRecords is null", function () { @@ -203,19 +203,19 @@ describe("A Paginator", function () { paginator.render(); - expect(paginator.$el.find("a").length).toBe(5); - expect(paginator.$el.find("a[title='No. 1']").length).toBe(1); - expect(paginator.$el.find("a[title='No. 2']").length).toBe(0); + expect($(paginator.el).find("a").length).toBe(5); + expect($(paginator.el).find("a[title='No. 1']").length).toBe(1); + expect($(paginator.el).find("a[title='No. 2']").length).toBe(0); }); it("refreshes upon collection reset", function () { books.reset([{ title: "Alice's Adventures in Wonderland" }]); - expect(paginator.$el.find("a").length).toBe(7); - expect(paginator.$el.find("a[title='No. 1']").length).toBe(1); - expect(paginator.$el.find("a[title='No. 2']").length).toBe(1); - expect(paginator.$el.find("a[title='No. 3']").length).toBe(1); + expect($(paginator.el).find("a").length).toBe(7); + expect($(paginator.el).find("a[title='No. 1']").length).toBe(1); + expect($(paginator.el).find("a[title='No. 2']").length).toBe(1); + expect($(paginator.el).find("a[title='No. 3']").length).toBe(1); }); }); @@ -251,9 +251,9 @@ describe("A Paginator", function () { columns: [{name: "title", cell: "string"}] }); paginator.render(); - expect(paginator.$el.find("a").length).toBe(2); - expect(paginator.$el.find("a").eq(0).html()).toBe("first"); - expect(paginator.$el.find("a").eq(1).html()).toBe("next"); + expect($(paginator.el).find("a").length).toBe(2); + expect($(paginator.el).find("a").eq(0).html()).toBe("first"); + expect($(paginator.el).find("a").eq(1).html()).toBe("next"); }); it("defined under any mode", function () { @@ -267,9 +267,9 @@ describe("A Paginator", function () { columns: [{name: "title", cell: "string"}] }); paginator.render(); - expect(paginator.$el.find("a").length).toBe(5); - expect(paginator.$el.find("a").eq(0).html()).toBe("first"); - expect(paginator.$el.find("a").eq(4).html()).toBe("next"); + expect($(paginator.el).find("a").length).toBe(5); + expect($(paginator.el).find("a").eq(0).html()).toBe("first"); + expect($(paginator.el).find("a").eq(4).html()).toBe("next"); }); }); diff --git a/test/extensions/select-all.js b/test/extensions/select-all.js index 7e8c1820..6e0b6b64 100644 --- a/test/extensions/select-all.js +++ b/test/extensions/select-all.js @@ -28,7 +28,7 @@ describe("A SelectRowCell", function () { }); it("renders a checkbox", function () { - expect(cell.$el.find(":checkbox").length).toBe(1); + expect($(cell.el).find(":checkbox").length).toBe(1); }); it("triggers a Backbone `backgrid:selected` event when the checkbox is checked", function () { @@ -36,15 +36,15 @@ describe("A SelectRowCell", function () { model.on("backgrid:selected", function () { selectedTriggered = true; }); - cell.$el.find(":checkbox").prop("checked", true).change(); + $(cell.el).find(":checkbox").prop("checked", true).change(); expect(selectedTriggered).toBe(true); }); it("checks or unchecks its checkbox when the model triggers a Backbone `backgrid:select` event", function () { model.trigger("backgrid:select", model, true); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(true); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(true); model.trigger("backgrid:select", model, false); - expect(cell.$el.find(":checkbox").prop("checked")).toBe(false); + expect($(cell.el).find(":checkbox").prop("checked")).toBe(false); }); }); @@ -74,7 +74,7 @@ describe("A SelectAllHeaderCell", function () { selectTriggerArgs.push(Array.prototype.slice.apply(arguments)); }); - cell.$el.find(":checkbox").prop("checked", true).change(); + $(cell.el).find(":checkbox").prop("checked", true).change(); expect(selectTriggerArgs.length).toBe(2); expect(selectTriggerArgs[0][0]).toBe(collection.at(0)); expect(selectTriggerArgs[0][1]).toBe(true); @@ -83,9 +83,9 @@ describe("A SelectAllHeaderCell", function () { }); it("unchecks itself when a model triggers a `backgrid:selected` event with a false value", function () { - cell.$el.find(":checkbox").prop("checked", true).change(); + $(cell.el).find(":checkbox").prop("checked", true).change(); collection.at(0).trigger("backgrid:selected", collection.at(0), false); - expect(cell.$el.find(":checkbox").prop("checked"), false); + expect($(cell.el).find(":checkbox").prop("checked"), false); }); it("will trigger a `backgrid:select` event on each previously selected model after a `backgrid:refresh` event", function () { @@ -94,7 +94,7 @@ describe("A SelectAllHeaderCell", function () { ids1 = ids1 + model.id; model.trigger("backgrid:selected", model, true); }); - cell.$el.find(":checkbox").prop("checked", true).change(); + $(cell.el).find(":checkbox").prop("checked", true).change(); collection.off("backgrid:select"); var ids2 = ''; diff --git a/test/extensions/select2-cell.js b/test/extensions/select2-cell.js index 98769ca9..d315fe5b 100644 --- a/test/extensions/select2-cell.js +++ b/test/extensions/select2-cell.js @@ -49,7 +49,7 @@ describe("A Select2CellEditor", function () { editor.setOptionValues(optionValues); editor.render(); expect(editor.el.tagName).toBe("SELECT"); - var $options = editor.$el.children(); + var $options = $(editor.el).children(); expect($options.length).toBe(2); expect($options.eq(0).val()).toBe("1"); expect($options.eq(0).prop("selected")).toBe(false); @@ -77,7 +77,7 @@ describe("A Select2CellEditor", function () { }); editor.render(); expect(editor.el.tagName).toBe("SELECT"); - var $options = editor.$el.children(); + var $options = $(editor.el).children(); expect($options.length).toBe(2); expect($options.eq(0).val()).toBe("1"); expect($options.eq(0).prop("selected")).toBe(false); @@ -102,7 +102,7 @@ describe("A Select2CellEditor", function () { editor.setOptionValues(optionGroupValues); editor.render(); - var $optionGroups = editor.$el.children(); + var $optionGroups = $(editor.el).children(); expect($optionGroups.length).toBe(2); var $group1 = $optionGroups.eq(0); @@ -151,7 +151,7 @@ describe("A Select2CellEditor", function () { return optionGroupValues; }); editor.render(); - var $optionGroups = editor.$el.children(); + var $optionGroups = $(editor.el).children(); expect($optionGroups.length).toBe(2); var $group1 = $optionGroups.eq(0); @@ -209,7 +209,7 @@ describe("A Select2CellEditor", function () { backgridDoneTriggerArgs = [].slice.call(arguments); }); - editor.$el.select2("val", 1).change(); + $(editor.el).select2("val", 1).change(); expect(editor.formatter.toRaw).toHaveBeenCalledWith("1"); expect(editor.formatter.toRaw.calls.length).toBe(1); expect(editor.model.get(editor.column.get("name"))).toBe("1"); @@ -281,7 +281,7 @@ describe("A Select2Cell", function () { cell.render(); - expect(cell.$el.hasClass("select2-cell")).toBe(true); + expect($(cell.el).hasClass("select2-cell")).toBe(true); }); it("renders the label of the selected option in display mode", function () { @@ -298,7 +298,7 @@ describe("A Select2Cell", function () { }); cell.render(); - expect(cell.$el.text()).toBe("Girl"); + expect($(cell.el).text()).toBe("Girl"); var cell = new (Backgrid.Extension.Select2Cell.extend({ optionValues: optionGroupValues @@ -313,7 +313,7 @@ describe("A Select2Cell", function () { }); cell.render(); - expect(cell.$el.text()).toBe("Banana"); + expect($(cell.el).text()).toBe("Banana"); }); it("throws TypeError when rendering a malformed option value list", function () { @@ -353,8 +353,8 @@ describe("A Select2Cell", function () { cell.render(); - cell.$el.click(); - expect(cell.$el.find(".select2-container").length).toBe(1); + $(cell.el).click(); + expect($(cell.el).find(".select2-container").length).toBe(1); expect(cell.currentEditor.select2Options).toEqual({containerCssClass: "select2-container", width: "resolve"}); }); diff --git a/test/extensions/text-cell.js b/test/extensions/text-cell.js index d89b7f2a..4ef34aeb 100644 --- a/test/extensions/text-cell.js +++ b/test/extensions/text-cell.js @@ -24,7 +24,7 @@ describe("A TextCell", function () { it("applies a text-cell class to the cell", function () { cell.render(); - expect(cell.$el.hasClass("text-cell")).toBe(true); + expect($(cell.el).hasClass("text-cell")).toBe(true); }); }); @@ -71,13 +71,13 @@ describe("A TextareaEditor", function () { }); it("renders a dialog form with a textarea, a submit button and close button according to config", function () { - expect(editor.$el.find("form").length).toBe(1); - expect(editor.$el.find("form textarea").length).toBe(1); - expect(editor.$el.find("form textarea").html()).toBe("name <script></script>"); - expect(editor.$el.find("form input[type=submit]").length).toBe(1); - expect(editor.$el.find("button.close").length).toBe(1); - expect(editor.$el.find("form textarea").prop("cols")).toBe(Backgrid.Extension.TextareaEditor.prototype.cols); - expect(editor.$el.find("form textarea").prop("rows")).toBe(Backgrid.Extension.TextareaEditor.prototype.rows); + expect($(editor.el).find("form").length).toBe(1); + expect($(editor.el).find("form textarea").length).toBe(1); + expect($(editor.el).find("form textarea").html()).toBe("name <script></script>"); + expect($(editor.el).find("form input[type=submit]").length).toBe(1); + expect($(editor.el).find("button.close").length).toBe(1); + expect($(editor.el).find("form textarea").prop("cols")).toBe(Backgrid.Extension.TextareaEditor.prototype.cols); + expect($(editor.el).find("form textarea").prop("rows")).toBe(Backgrid.Extension.TextareaEditor.prototype.rows); }); it("asks for confirmation if textarea is dirty when canceling", function () { @@ -89,8 +89,8 @@ describe("A TextareaEditor", function () { confirmArgs = [].slice.call(arguments); return false; }; - editor.$el.find("textarea").val("name\r"); - editor.$el.find(".close").click(); + $(editor.el).find("textarea").val("name\r"); + $(editor.el).find(".close").click(); expect(confirmArgs[0]).toBe("Would you like to save your changes?"); }); @@ -111,8 +111,8 @@ describe("A TextareaEditor", function () { return true; }; editor.render(); - editor.$el.find("textarea").val("name\r"); - editor.$el.find(".close").click(); + $(editor.el).find("textarea").val("name\r"); + $(editor.el).find(".close").click(); expect(confirmArgs[0]).toBe("Would you like to save your changes?"); }); @@ -135,7 +135,7 @@ describe("A TextareaEditor", function () { }; editor.model.unset("name"); editor.render(); - editor.$el.find(".close").click(); + $(editor.el).find(".close").click(); expect(confirmArgs).toBeNull(); }); @@ -154,8 +154,8 @@ describe("A TextareaEditor", function () { }); it("saves the text from the textarea to the model and trigger 'backgrid:edited' from the model when the form is submitted", function () { - editor.$el.find("textarea").val("another name"); - editor.$el.find("form").submit(); + $(editor.el).find("textarea").val("another name"); + $(editor.el).find("form").submit(); waitsFor(function () { return backgridEditedTriggerCount === 1; }); @@ -170,8 +170,8 @@ describe("A TextareaEditor", function () { it("triggers 'backgrid:error' from the model if the formatter returns undefined", function () { editor.formatter.toRaw = function () {}; - editor.$el.find("textarea").val("another name"); - editor.$el.find("form").submit(); + $(editor.el).find("textarea").val("another name"); + $(editor.el).find("form").submit(); expect(backgridErrorTriggerCount).toBe(1); expect(backgridErrorTriggerArgs[0]).toBe(editor.model); expect(backgridErrorTriggerArgs[1]).toBe(editor.column); diff --git a/test/header.js b/test/header.js index c61be3f4..8655dcd6 100644 --- a/test/header.js +++ b/test/header.js @@ -44,23 +44,23 @@ describe("A HeaderCell", function () { it("renders a table header cell with an anchor wrapping the label text and the sort caret", function () { expect(cell.el.tagName).toBe("TH"); - expect(cell.$el.find("a").text()).toBe("id"); - expect(cell.$el.find(".sort-caret").length).toBe(1); + expect($(cell.el).find("a").text()).toBe("id"); + expect($(cell.el).find(".sort-caret").length).toBe(1); }); it("sorts the underlying collection in ascending order upon clicking the sort caret once", function () { - cell.$el.find("a").click(); + $(cell.el).find("a").click(); expect(cell.collection.toJSON()).toEqual([{id: 1}, {id: 2}, {id: 3}]); }); it("sorts the underlying collection in descending order upon clicking the sort caret twice", function () { - cell.$el.find("a").click().click(); + $(cell.el).find("a").click().click(); expect(cell.direction()).toBe("descending"); expect(cell.collection.toJSON()).toEqual([{id: 3}, {id: 2}, {id: 1}]); }); it("sorts the underlying collection in default order upon clicking the sort caret thrice", function () { - cell.$el.find("a").click().click().click(); + $(cell.el).find("a").click().click().click(); expect(cell.direction()).toBeNull(); expect(cell.collection.toJSON()).toEqual([{id: 2}, {id: 1}, {id: 3}]); }); @@ -92,7 +92,7 @@ describe("A HeaderCell", function () { expect(cell.collection.at(0).get("id")).toBe(1); expect(cell.collection.at(1).get("id")).toBe(2); - cell.$el.find("a").click().click(); + $(cell.el).find("a").click().click(); expect(cell.collection.at(0).get("id")).toBe(2); expect(cell.collection.at(1).get("id")).toBe(1); @@ -125,7 +125,7 @@ describe("A HeaderCell", function () { cell.render(); - cell.$el.find("a").click(); + $(cell.el).find("a").click(); expect(cell.collection.toJSON()).toEqual([{ title: "A Tale of Two Cities" @@ -145,13 +145,13 @@ describe("A HeaderCell", function () { cell.collection.getFirstPage(); - cell.$el.find("a").click(); + $(cell.el).find("a").click(); expect(cell.collection.toJSON()).toEqual([{ title: "The Catcher in the Rye" }]); - cell.$el.find("a").click(); + $(cell.el).find("a").click(); expect(cell.collection.toJSON()).toEqual([{ title: "Alice's Adventures in Wonderland" @@ -219,31 +219,31 @@ describe("A HeaderRow", function () { }); it("renders a row of header cells", function () { - expect(row.$el[0].tagName).toBe("TR"); - expect(row.$el[0].innerHTML).toBe('name' + + expect($(row.el)[0].tagName).toBe("TR"); + expect($(row.el)[0].innerHTML).toBe('name' + 'year'); }); 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("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); }); it("inserts or removes a cell if a column is added or removed", function () { row.columns.add({name: "price", cell: "number"}); - expect(row.$el.children().length).toBe(3); - expect(row.$el.children().last()[0].outerHTML).toBe('price'); + expect($(row.el).children().length).toBe(3); + expect($(row.el).children().last()[0].outerHTML).toBe('price'); 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().css("display")).toBe("none"); + expect($(row.el).children().length).toBe(4); + expect($(row.el).children().last().find("a").text()).toBe("publisher"); + expect($(row.el).children().last().css("display")).toBe("none"); row.columns.remove(row.columns.first()); - expect(row.$el.children().length).toBe(3); - expect(row.$el.children().first()[0].outerHTML).toBe('year'); + expect($(row.el).children().length).toBe(3); + expect($(row.el).children().first()[0].outerHTML).toBe('year'); }); }); @@ -306,8 +306,8 @@ describe("A Header", function () { }); it("renders a header with a row of header cells", function () { - expect(head.$el[0].tagName).toBe("THEAD"); - expect(head.$el[0].innerHTML).toBe('name' + + expect($(head.el)[0].tagName).toBe("THEAD"); + expect($(head.el)[0].innerHTML).toBe('name' + 'year'); }); diff --git a/test/row.js b/test/row.js index 73e9c8ce..202d9bee 100644 --- a/test/row.js +++ b/test/row.js @@ -45,7 +45,7 @@ describe("A Row", function () { expect(row.el.tagName).toBe("TR"); - var $tds = row.$el.children(); + var $tds = $(row.el).children(); expect($tds.eq(0).text()).toBe("name"); expect($tds.eq(1).text()).toBe("18"); }); @@ -64,17 +64,17 @@ describe("A Row", function () { row.render(); - var $tds = row.$el.children(); + var $tds = $(row.el).children(); expect($tds.eq(0).text()).toBe("name"); expect($tds.eq(0).css("display")).not.toBe("none"); row.columns.at(0).set("renderable", false); - $tds = row.$el.children(); + $tds = $(row.el).children(); expect($tds.eq(0).text()).toBe("name"); expect($tds.eq(0).css("display")).toBe("none"); row.columns.at(0).set("renderable", true); - $tds = row.$el.children(); + $tds = $(row.el).children(); expect($tds.eq(0).text()).toBe("name"); expect($tds.eq(0).css("display")).not.toBe("none"); }); @@ -95,17 +95,17 @@ describe("A Row", function () { row.render(); row.columns.add({name: "age", cell: "integer"}); - var $tds = row.$el.children(); + var $tds = $(row.el).children(); expect($tds.length).toBe(2); expect($tds.eq(1).text()).toBe("18"); row.columns.add({name: "birthday", cell: "date", renderable: false}); - $tds = row.$el.children(); + $tds = $(row.el).children(); expect($tds.length).toBe(3); expect($tds.last().text()).toBe("1987-06-05"); row.columns.remove(row.columns.first()); - $tds = row.$el.children(); + $tds = $(row.el).children(); expect($tds.length).toBe(2); expect($tds.first().text()).toBe("18"); expect($tds.last().text()).toBe("1987-06-05"); From 586661c95d972a440337b32796cca9f75f8c2623 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Mon, 29 Apr 2013 05:34:32 +0800 Subject: [PATCH 02/31] Minify js --- lib/backgrid.js | 380 +++++++++++++----- lib/backgrid.min.js | 2 +- lib/extensions/filter/backgrid-filter.js | 28 +- lib/extensions/filter/backgrid-filter.min.js | 2 +- .../moment-cell/backgrid-moment-cell.js | 4 +- .../moment-cell/backgrid-moment-cell.min.js | 2 +- .../paginator/backgrid-paginator.js | 18 +- .../paginator/backgrid-paginator.min.js | 2 +- .../select-all/backgrid-select-all.js | 32 +- .../select-all/backgrid-select-all.min.js | 2 +- .../select2-cell/backgrid-select2-cell.js | 6 +- .../select2-cell/backgrid-select2-cell.min.js | 2 +- .../text-cell/backgrid-text-cell.js | 2 + .../text-cell/backgrid-text-cell.min.js | 2 +- 14 files changed, 336 insertions(+), 148 deletions(-) diff --git a/lib/backgrid.js b/lib/backgrid.js index f674e5e9..f8227b1a 100644 --- a/lib/backgrid.js +++ b/lib/backgrid.js @@ -160,6 +160,153 @@ _.extend(Command.prototype, { } }); +var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; + +/** + @class Backgrid.View + @constructor + */ +var View = Backgrid.View = function(options) { + this.cid = _.uniqueId('view'); + this.options = options = options || {}; + _.extend(this, _.pick(options, viewOptions)); + this._ensureElement(options); + this.initialize.apply(this, arguments); + this.delegateEvents(); +}; + +var delegateEventSplitter = /^(\S+)\s*(.*)$/; + +_.extend(View.prototype, Backbone.Events, { + + use$: false, + + tagName: 'div', + + $: function(selector) { + return this.$el ? this.$el.find(selector) : this.el.querySelectorAll(selector); + }, + + initialize: function(){}, + + render: function() { + return this; + }, + + empty: function () { + if (this.$el) this.$el.remove(); + else { + var el = this.el; + while (el.hasChildNodes()) { + el.removeChild(el.firstChild); + } + } + return this; + }, + + remove: function() { + this.empty(); + this.stopListening(); + return this; + }, + + setElement: function(element, options) { + options = _.extend({use$: Backbone.$ && this.use$, delegate: true}, options || {}); + var delegate = options.delegate; + if (this.el) this.undelegateEvents(); + this.el = element; + if (options.use$) this.$el = Backbone.$(element); + if (delegate !== false) this.delegateEvents(); + return this; + }, + + _processEvents: function(events, func) { + for (var key in events) { + var method = events[key]; + if (!_.isFunction(method)) method = this[events[key]]; + if (!method) continue; + + method = _.bind(method, this); + var match = key.match(delegateEventSplitter); + func(match[1], match[2], method); + } + }, + + delegateEvents: function(events) { + if (!(events || (events = _.result(this, 'events')))) return this; + this.undelegateEvents(); + var el = this.el, $el = this.$el, cid = this.cid; + this._processEvents(events, function (eventName, selector, method) { + var namespacedEventName = eventName + '.delegateEvents' + cid; + if (selector === '') { + if ($el) $el.on(namespacedEventName, method); + else if (el.addEventListener) el.addEventListener(eventName, method); + else if (el.attachEvent) el.attachEvent('on' + eventName, method); + } else { + if ($el) $el.on(namespacedEventName, selector, method); + else { + var descendants = el.querySelectorAll(selector); + for (var i = 0, l = descendants.length; i < l; i++) { + var descendant = descendants[i]; + if (el.addEventListener) { + descendant.addEventListener(eventName, method); + } + else if (el.attachEvent) { + descendant.attachEvent('on' + eventName, method); + } + } + } + } + }); + return this; + }, + + undelegateEvents: function() { + var events = _.result(this, 'events'); + if (!events) return this; + if (this.$el) this.$el.off('.delegateEvents' + this.cid); + else { + var el = this.el; + this._processEvents(events, function (eventName, selector, method) { + if (selector === '') { + if (el.removeEventListener) el.removeEventListener(eventName, method); + if (el.detachEvent) el.detachEvent('on' + eventName, method); + } else { + var descendants = el.querySelectorAll(selector); + for (var i = 0, l = descendants.length; i < l; i++) { + var descendant = descendants[i]; + if (el.removeEventListener) { + descendant.removeEventListener(eventName, method); + } + else if (el.detachEvent) { + descendant.detachEvent('on' + eventName, method); + } + } + } + }); + } + return this; + }, + + _ensureElement: function(options) { + options = _.extend(options, {delegate: false}); + if (!this.el) { + var el = this.el = window.document.createElement(this.tagName); + var attrs = _.extend({}, _.result(this, 'attributes')); + if (this.id) attrs.id = _.result(this, 'id'); + if (this.className) attrs['class'] = _.result(this, 'className'); + for (var k in attrs) { + el.setAttribute(k, attrs[k]); + } + this.setElement(el, options); + } else { + this.setElement(_.result(this, 'el'), options); + } + } + +}); + +View.extend = Backbone.View.extend; /* backgrid http://github.com/wyuenho/backgrid @@ -498,9 +645,9 @@ _.extend(EmailFormatter.prototype, { @abstract @class Backgrid.CellEditor - @extends Backbone.View + @extends Backgrid.View */ -var CellEditor = Backgrid.CellEditor = Backbone.View.extend({ +var CellEditor = Backgrid.CellEditor = Backgrid.View.extend({ /** Initializer. @@ -531,7 +678,7 @@ var CellEditor = Backgrid.CellEditor = Backbone.View.extend({ */ postRender: function (model, column) { if (column == null || column.get("name") == this.column.get("name")) { - this.$el.focus(); + this.el.focus(); } return this; } @@ -576,7 +723,7 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ CellEditor.prototype.initialize.apply(this, arguments); if (options.placeholder) { - this.$el.attr("placeholder", options.placeholder); + this.el.setAttribute("placeholder", options.placeholder); } }, @@ -585,7 +732,7 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ exists. */ render: function () { - this.$el.val(this.formatter.fromRaw(this.model.get(this.column.get("name")))); + this.el.value = this.formatter.fromRaw(this.model.get(this.column.get("name"))); return this; }, @@ -621,7 +768,7 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ e.preventDefault(); e.stopPropagation(); - var val = this.$el.val(); + var val = this.el.value; var newValue = formatter.toRaw(val); if (_.isUndefined(newValue)) { model.trigger("backgrid:error", model, column, val); @@ -642,11 +789,18 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ postRender: function (model, column) { if (column == null || column.get("name") == this.column.get("name")) { // move the cursor to the end on firefox if text is right aligned - if (this.$el.css("text-align") === "right") { - var val = this.$el.val(); - this.$el.focus().val(null).val(val); + var el = this.el, textAlign; + if (window.getComputedStyle) { + textAlign = window.getComputedStyle(el).textAlign; } - else this.$el.focus(); + else if (el.currentStyle) textAlign = el.currentStyle.textAlign; + if (textAlign === "right") { + var val = el.value; + el.focus(); + el.val = null; + el.val = val; + } + else el.focus(); } return this; } @@ -663,9 +817,9 @@ var InputCellEditor = Backgrid.InputCellEditor = CellEditor.extend({ @abstract @class Backgrid.Cell - @extends Backbone.View + @extends Backgrid.View */ -var Cell = Backgrid.Cell = Backbone.View.extend({ +var Cell = Backgrid.Cell = Backgrid.View.extend({ /** @property */ tagName: "td", @@ -708,17 +862,28 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ this.formatter = Backgrid.resolveNameToClass(this.column.get("formatter") || this.formatter, "Formatter"); this.editor = Backgrid.resolveNameToClass(this.editor, "CellEditor"); this.listenTo(this.model, "change:" + this.column.get("name"), function () { - if (!this.$el.hasClass("editor")) this.render(); + if (!this.el.classList.contains("editor")) this.render(); }); }, + show: function () { + this.el.style.display = ''; + return this; + }, + + hide: function () { + this.el.style.display = "none"; + return this; + }, + /** Render a text string in a table cell. The text is converted from the model's raw value for this cell's column. */ render: function () { - this.$el.empty(); - this.$el.text(this.formatter.fromRaw(this.model.get(this.column.get("name")))); + this.empty(); + this.el.appendChild(window.document.createTextNode( + this.formatter.fromRaw(this.model.get(this.column.get("name"))))); this.delegateEvents(); return this; }, @@ -760,10 +925,10 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ // Need to redundantly undelegate events for Firefox this.undelegateEvents(); - this.$el.empty(); - this.$el.append(this.currentEditor.$el); + this.empty(); + this.el.appendChild(this.currentEditor.el); this.currentEditor.render(); - this.$el.addClass("editor"); + this.el.classList.add("editor"); model.trigger("backgrid:editing", model, column, this, this.currentEditor); } @@ -774,7 +939,7 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ */ renderError: function (model, column) { if (column == null || column.get("name") == this.column.get("name")) { - this.$el.addClass("error"); + this.el.classList.add("error"); } }, @@ -782,11 +947,11 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ Removes the editor and re-render in display mode. */ exitEditMode: function () { - this.$el.removeClass("error"); + this.el.classList.remove("error"); this.currentEditor.remove(); this.stopListening(this.currentEditor); delete this.currentEditor; - this.$el.removeClass("editor"); + this.el.classList.remove("editor"); this.render(); }, @@ -800,7 +965,7 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ this.currentEditor.remove.apply(this, arguments); delete this.currentEditor; } - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); } }); @@ -837,14 +1002,16 @@ var UriCell = Backgrid.UriCell = Cell.extend({ className: "uri-cell", render: function () { - this.$el.empty(); + this.empty(); var formattedValue = this.formatter.fromRaw(this.model.get(this.column.get("name"))); - this.$el.append($("", { - tabIndex: -1, - href: formattedValue, - title: formattedValue, - target: "_blank" - }).text(formattedValue)); + var doc = window.document; + var a = doc.createElement("a"); + a.tabIndex = -1; + a.href = formattedValue; + a.title = formattedValue; + a.target = "_blank"; + a.appendChild(doc.createTextNode(formattedValue)); + this.el.appendChild(a); this.delegateEvents(); return this; } @@ -867,13 +1034,15 @@ var EmailCell = Backgrid.EmailCell = StringCell.extend({ formatter: new EmailFormatter(), render: function () { - this.$el.empty(); + this.empty(); var formattedValue = this.formatter.fromRaw(this.model.get(this.column.get("name"))); - this.$el.append($("", { - tabIndex: -1, - href: "mailto:" + formattedValue, - title: formattedValue - }).text(formattedValue)); + var doc = window.document; + var a = doc.createElement("a"); + a.tabIndex = -1; + a.href = "mailto:" + formattedValue; + a.title = formattedValue; + a.appendChild(doc.createTextNode(formattedValue)); + this.el.appendChild(a); this.delegateEvents(); return this; } @@ -1077,7 +1246,7 @@ var BooleanCellEditor = Backgrid.BooleanCellEditor = CellEditor.extend({ */ render: function () { var val = this.formatter.fromRaw(this.model.get(this.column.get("name"))); - this.$el.prop("checked", val); + this.el.checked = val; return this; }, @@ -1109,19 +1278,19 @@ var BooleanCellEditor = Backgrid.BooleanCellEditor = CellEditor.extend({ model.trigger("backgrid:edited", model, column, command); } - var $el = this.$el; + var el = this.el; if (command.save() || command.moveLeft() || command.moveRight() || command.moveUp() || command.moveDown()) { e.preventDefault(); e.stopPropagation(); - var val = formatter.toRaw($el.prop("checked")); + var val = formatter.toRaw(el.checked); model.set(column.get("name"), val); model.trigger("backgrid:edited", model, column, command); } else if (e.type == "change") { - var val = formatter.toRaw($el.prop("checked")); + var val = formatter.toRaw(el.checked); model.set(column.get("name"), val); - $el.focus(); + el.focus(); } } @@ -1152,12 +1321,12 @@ var BooleanCell = Backgrid.BooleanCell = Cell.extend({ uncheck otherwise. */ render: function () { - this.$el.empty(); - this.$el.append($("", { - tabIndex: -1, - type: "checkbox", - checked: this.formatter.fromRaw(this.model.get(this.column.get("name"))) - })); + this.empty(); + var input = window.document.createElement("input"); + input.tabIndex = -1; + input.type = "checkbox"; + input.checked = this.formatter.fromRaw(this.model.get(this.column.get("name"))); + this.el.appendChild(input); this.delegateEvents(); return this; } @@ -1209,7 +1378,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ parameter. */ render: function () { - this.$el.empty(); + this.empty(); var optionValues = _.result(this, "optionValues"); var currentValue = this.model.get(this.column.get("name")); @@ -1221,6 +1390,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ var optionValue = null; var optgroupName = null; var optgroup = null; + var innerHTML = ''; for (var i = 0; i < optionValues.length; i++) { var optionValue = optionValues[i]; @@ -1228,23 +1398,24 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ optionText = optionValue[0]; optionValue = optionValue[1]; - this.$el.append(this.template({ + innerHTML += this.template({ text: optionText, value: optionValue, selected: optionValue == currentValue - })); + }); } else if (_.isObject(optionValue)) { optgroupName = optionValue.name; - optgroup = $("", { label: optgroupName }); - optgroup.append(this._renderOptions(optionValue.values, currentValue)); - this.$el.append(optgroup); + optgroup = this._renderOptions(optionValue.values, currentValue); + innerHTML = innerHTML + '' + optgroup + ''; } else { throw TypeError("optionValues elements must be a name-value pair or an object hash of { name: 'optgroup label', value: [option name-value pairs] }"); } } + this.el.innerHTML = innerHTML; + this.delegateEvents(); return this; @@ -1257,7 +1428,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ save: function (e) { var model = this.model; var column = this.column; - model.set(column.get("name"), this.formatter.toRaw(this.$el.val())); + model.set(column.get("name"), this.formatter.toRaw(this.el.value)); model.trigger("backgrid:edited", model, column, new Command(e)); }, @@ -1351,14 +1522,14 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ @throws {TypeError} If `optionValues` is malformed. */ render: function () { - this.$el.empty(); + this.empty(); var optionValues = this.optionValues; var rawData = this.formatter.fromRaw(this.model.get(this.column.get("name"))); try { if (!_.isArray(optionValues) || _.isEmpty(optionValues)) throw new TypeError; - + var doc = window.document; for (var i = 0; i < optionValues.length; i++) { var optionValue = optionValues[i]; @@ -1367,7 +1538,7 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ var optionValue = optionValue[1]; if (optionValue == rawData) { - this.$el.append(optionText); + this.el.appendChild(doc.createTextNode(optionText)); break; } } @@ -1376,7 +1547,7 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ for (var j = 0; j < optionGroupValues.length; j++) { var optionGroupValue = optionGroupValues[j]; if (optionGroupValue[1] == rawData) { - this.$el.append(optionGroupValue[0]); + this.el.appendChild(doc.createTextNode(optionGroupValue[0])); break; } } @@ -1498,9 +1669,9 @@ var Columns = Backgrid.Columns = Backbone.Collection.extend({ rendered, and apply the appropriate cell to each attribute. @class Backgrid.Row - @extends Backbone.View + @extends Backgrid.View */ -var Row = Backgrid.Row = Backbone.View.extend({ +var Row = Backgrid.Row = Backgrid.View.extend({ /** @property */ tagName: "tr", @@ -1534,7 +1705,7 @@ var Row = Backgrid.Row = Backbone.View.extend({ for (var i = 0; i < cells.length; i++) { var cell = cells[i]; if (cell.column.get("name") == column.get("name")) { - if (renderable) cell.$el.show(); else cell.$el.hide(); + if (renderable) cell.show(); else cell.hide(); } } }); @@ -1544,17 +1715,17 @@ var Row = Backgrid.Row = Backbone.View.extend({ var cell = this.makeCell(column, options); cells.splice(i, 0, cell); - if (!cell.column.get("renderable")) cell.$el.hide(); + if (!cell.column.get("renderable")) cell.hide(); - var $el = this.$el; + var el = this.el, children = el.childNodes(); if (i === 0) { - $el.prepend(cell.render().$el); + el.insertBefore(cell.render().el, el.firstChild); } else if (i === columns.length - 1) { - $el.append(cell.render().$el); + el.appendChild(cell.render().el); } else { - $el.children().eq(i).before(cell.render().$el); + el.insertBefore(cell.render().el, children[i]); } }); @@ -1586,14 +1757,14 @@ var Row = Backgrid.Row = Backbone.View.extend({ Renders a row of cells for this row's model. */ render: function () { - this.$el.empty(); + this.empty(); var fragment = document.createDocumentFragment(); for (var i = 0; i < this.cells.length; i++) { var cell = this.cells[i]; fragment.appendChild(cell.render().el); - if (!cell.column.get("renderable")) cell.$el.hide(); + if (!cell.column.get("renderable")) cell.hide(); } this.el.appendChild(fragment); @@ -1613,7 +1784,7 @@ var Row = Backgrid.Row = Backbone.View.extend({ var cell = this.cells[i]; cell.remove.apply(cell, arguments); } - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); } }); @@ -1623,9 +1794,9 @@ var Row = Backgrid.Row = Backbone.View.extend({ row with a single column. @class Backgrid.EmptyRow - @extends Backbone.View + @extends Backgrid.View */ -var EmptyRow = Backgrid.EmptyRow = Backbone.View.extend({ +var EmptyRow = Backgrid.EmptyRow = Backgrid.View.extend({ /** @property */ tagName: "tr", @@ -1651,7 +1822,7 @@ var EmptyRow = Backgrid.EmptyRow = Backbone.View.extend({ Renders an empty row. */ render: function () { - this.$el.empty(); + this.empty(); var td = document.createElement("td"); td.setAttribute("colspan", this.columns.length); @@ -1677,9 +1848,9 @@ var EmptyRow = Backgrid.EmptyRow = Backbone.View.extend({ refresh after sorting. @class Backgrid.HeaderCell - @extends Backbone.View + @extends Backgrid.View */ -var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ +var HeaderCell = Backgrid.HeaderCell = Backgrid.View.extend({ /** @property */ tagName: "th", @@ -1722,8 +1893,8 @@ var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ */ direction: function (dir) { if (arguments.length) { - if (this._direction) this.$el.removeClass(this._direction); - if (dir) this.$el.addClass(dir); + if (this._direction) this.el.classList.remove(this._direction); + if (dir) this.el.classList.add(dir); this._direction = dir; } @@ -1857,9 +2028,14 @@ var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ Renders a header cell with a sorter and a label. */ render: function () { - this.$el.empty(); - var $label = $("").text(this.column.get("label")).append(""); - this.$el.append($label); + this.empty(); + var doc = window.document; + var label = doc.createElement("a"); + label.appendChild(doc.createTextNode(this.column.get("label"))); + var caret = doc.createElement("b"); + caret.className = "sort-caret"; + label.appendChild(caret); + this.el.appendChild(label); this.delegateEvents(); return this; } @@ -1908,9 +2084,9 @@ var HeaderRow = Backgrid.HeaderRow = Backgrid.Row.extend({ single row of header cells. @class Backgrid.Header - @extends Backbone.View + @extends Backgrid.View */ -var Header = Backgrid.Header = Backbone.View.extend({ +var Header = Backgrid.Header = Backgrid.View.extend({ /** @property */ tagName: "thead", @@ -1943,7 +2119,7 @@ var Header = Backgrid.Header = Backbone.View.extend({ Renders this table head with a single row of header cells. */ render: function () { - this.$el.append(this.row.render().$el); + this.el.appendChild(this.row.render().el); this.delegateEvents(); return this; }, @@ -1955,7 +2131,7 @@ var Header = Backgrid.Header = Backbone.View.extend({ */ remove: function () { this.row.remove.apply(this.row, arguments); - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); } }); @@ -1972,9 +2148,9 @@ var Header = Backgrid.Header = Backbone.View.extend({ responsible for refreshing the rows after sorting, insertion and removal. @class Backgrid.Body - @extends Backbone.View + @extends Backgrid.View */ -var Body = Backgrid.Body = Backbone.View.extend({ +var Body = Backgrid.Body = Backgrid.View.extend({ /** @property */ tagName: "tbody", @@ -2074,16 +2250,16 @@ var Body = Backgrid.Body = Backbone.View.extend({ var index = collection.indexOf(model); this.rows.splice(index, 0, row); - var $el = this.$el; - var $children = $el.children(); - var $rowEl = row.render().$el; + var el = this.el; + var children = el.childNodes(); + var rowEl = row.render().el; if (options.render) { - if (index >= $children.length) { - $el.append($rowEl); + if (index >= children.length) { + el.appendChild(rowEl); } else { - $children.eq(index).before($rowEl); + el.insertBefore(rowEl, children[index]); } } }, @@ -2162,7 +2338,7 @@ var Body = Backgrid.Body = Backbone.View.extend({ row is rendered, otherwise no row is rendered. */ render: function () { - this.$el.empty(); + this.empty(); var fragment = document.createDocumentFragment(); for (var i = 0; i < this.rows.length; i++) { @@ -2187,7 +2363,7 @@ var Body = Backgrid.Body = Backbone.View.extend({ var row = this.rows[i]; row.remove.apply(row, arguments); } - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); }, /** @@ -2245,9 +2421,9 @@ var Body = Backgrid.Body = Backbone.View.extend({ @abstract @class Backgrid.Footer - @extends Backbone.View + @extends Backgrid.View */ -var Footer = Backgrid.Footer = Backbone.View.extend({ +var Footer = Backgrid.Footer = Backgrid.View.extend({ /** @property */ tagName: "tfoot", @@ -2286,7 +2462,7 @@ var Footer = Backgrid.Footer = Backbone.View.extend({ By default, a Grid treats each model in a collection as a row, and each attribute in a model as a column. To render a grid you must provide a list of column metadata and a collection to the Grid constructor. Just like any - Backbone.View class, the grid is rendered as a DOM node fragment when you + Backgrid.View class, the grid is rendered as a DOM node fragment when you call render(). var grid = Backgrid.Grid({ @@ -2317,7 +2493,7 @@ var Footer = Backgrid.Footer = Backbone.View.extend({ Row class. @class Backgrid.Grid - @extends Backbone.View + @extends Backgrid.View See: @@ -2327,7 +2503,7 @@ var Footer = Backgrid.Footer = Backbone.View.extend({ - Backgrid.Row - Backgrid.Footer */ -var Grid = Backgrid.Grid = Backbone.View.extend({ +var Grid = Backgrid.Grid = Backgrid.View.extend({ /** @property */ tagName: "table", @@ -2440,15 +2616,15 @@ var Grid = Backgrid.Grid = Backbone.View.extend({ the it has successfully been rendered. */ render: function () { - this.$el.empty(); + this.empty(); - this.$el.append(this.header.render().$el); + this.el.appendChild(this.header.render().el); if (this.footer) { - this.$el.append(this.footer.render().$el); + this.el.appendChild(this.footer.render().el); } - this.$el.append(this.body.render().$el); + this.el.appendChild(this.body.render().el); this.delegateEvents(); @@ -2466,7 +2642,7 @@ var Grid = Backgrid.Grid = Backbone.View.extend({ this.header.remove.apply(this.header, arguments); this.body.remove.apply(this.body, arguments); this.footer && this.footer.remove.apply(this.footer, arguments); - return Backbone.View.prototype.remove.apply(this, arguments); + return Backgrid.View.prototype.remove.apply(this, arguments); } }); diff --git a/lib/backgrid.min.js b/lib/backgrid.min.js index 00bbcdab..7e0a7563 100644 --- a/lib/backgrid.min.js +++ b/lib/backgrid.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,i,n){"use strict";function r(e){return String.fromCharCode(e.charCodeAt(0)-32)+e.slice(1)}function o(e,t,i){var n=t-(e+"").length;n=0>n?0:n;for(var r="",o=0;n>o;o++)r+=i;return r+e}var s=" \n \f\r   ᠎              \u2028\u2029";if(!String.prototype.trim||s.trim()){s="["+s+"]";var l=RegExp("^"+s+s+"*"),a=RegExp(s+s+"*$");String.prototype.trim=function(){if(void 0===this||null===this)throw new TypeError("can't convert "+this+" to object");return(this+"").replace(l,"").replace(a,"")}}var h=e.Backgrid={VERSION:"0.2.5",Extension:{},requireOptions:function(e,t){for(var n=0;t.length>n;n++){var r=t[n];if(i.isUndefined(e[r]))throw new TypeError("'"+r+"' is required")}},resolveNameToClass:function(e,t){if(i.isString(e)){var n=i.map(e.split("-"),function(e){return r(e)}).join("")+t,o=h[n]||h.Extension[n];if(i.isUndefined(o))throw new ReferenceError("Class '"+n+"' not found");return o}return e}};i.extend(h,n.Events);var c=h.Command=function(e){i.extend(this,{altKey:!!e.altKey,"char":e.char,charCode:e.charCode,ctrlKey:!!e.ctrlKey,key:e.key,keyCode:e.keyCode,locale:e.locale,location:e.location,metaKey:!!e.metaKey,repeat:!!e.repeat,shiftKey:!!e.shiftKey,which:e.which})};i.extend(c.prototype,{moveUp:function(){return 38==this.keyCode},moveDown:function(){return 40===this.keyCode},moveLeft:function(){return this.shiftKey&&9===this.keyCode},moveRight:function(){return!this.shiftKey&&9===this.keyCode},save:function(){return 13===this.keyCode},cancel:function(){return 27===this.keyCode},passThru:function(){return!(this.moveUp()||this.moveDown()||this.moveLeft()||this.moveRight()||this.save()||this.cancel())}});var d=h.CellFormatter=function(){};i.extend(d.prototype,{fromRaw:function(e){return e},toRaw:function(e){return e}});var u=h.NumberFormatter=function(e){if(e=e?i.clone(e):{},i.extend(this,this.defaults,e),0>this.decimals||this.decimals>20)throw new RangeError("decimals must be between 0 and 20")};u.prototype=new d,i.extend(u.prototype,{defaults:{decimals:2,decimalSeparator:".",orderSeparator:","},HUMANIZED_NUM_RE:/(\d)(?=(?:\d{3})+$)/g,fromRaw:function(e){if(i.isNull(e)||i.isUndefined(e))return"";e=e.toFixed(~~this.decimals);var t=e.split("."),n=t[0],r=t[1]?(this.decimalSeparator||".")+t[1]:"";return n.replace(this.HUMANIZED_NUM_RE,"$1"+this.orderSeparator)+r},toRaw:function(e){for(var t="",n=e.trim().split(this.orderSeparator),r=0;n.length>r;r++)t+=n[r];var o=t.split(this.decimalSeparator);t="";for(var r=0;o.length>r;r++)t=t+o[r]+".";"."===t[t.length-1]&&(t=t.slice(0,t.length-1));var s=1*(1*t).toFixed(~~this.decimals);return i.isNumber(s)&&!i.isNaN(s)?s:void 0}});var m=h.DatetimeFormatter=function(e){if(e=e?i.clone(e):{},i.extend(this,this.defaults,e),!this.includeDate&&!this.includeTime)throw Error("Either includeDate or includeTime must be true")};m.prototype=new d,i.extend(m.prototype,{defaults:{includeDate:!0,includeTime:!0,includeMilli:!1},DATE_RE:/^([+\-]?\d{4})-(\d{2})-(\d{2})$/,TIME_RE:/^(\d{2}):(\d{2}):(\d{2})(\.(\d{3}))?$/,ISO_SPLITTER_RE:/T|Z| +/,_convert:function(e,t){e=e.trim();var n=e.split(this.ISO_SPLITTER_RE)||[],r=this.DATE_RE.test(n[0])?n[0]:"",s=r&&n[1]?n[1]:this.TIME_RE.test(n[0])?n[0]:"",l=this.DATE_RE.exec(r)||[],a=this.TIME_RE.exec(s)||[];if(t){if(this.includeDate&&i.isUndefined(l[0]))return;if(this.includeTime&&i.isUndefined(a[0]))return;if(!this.includeDate&&r)return;if(!this.includeTime&&s)return}var h=new Date(Date.UTC(1*l[1]||0,1*l[2]-1||0,1*l[3]||0,1*a[1]||null,1*a[2]||null,1*a[3]||null,1*a[5]||null)),c="";return this.includeDate&&(c=o(h.getUTCFullYear(),4,0)+"-"+o(h.getUTCMonth()+1,2,0)+"-"+o(h.getUTCDate(),2,0)),this.includeTime&&(c=c+(this.includeDate?"T":"")+o(h.getUTCHours(),2,0)+":"+o(h.getUTCMinutes(),2,0)+":"+o(h.getUTCSeconds(),2,0),this.includeMilli&&(c=c+"."+o(h.getUTCMilliseconds(),3,0))),this.includeDate&&this.includeTime&&(c+="Z"),c},fromRaw:function(e){return i.isNull(e)||i.isUndefined(e)?"":this._convert(e)},toRaw:function(e){return this._convert(e,!0)}});var p=h.StringFormatter=function(){};p.prototype=new d,i.extend(p.prototype,{fromRaw:function(e){return i.isUndefined(e)||i.isNull(e)?"":e+""}});var f=h.EmailFormatter=function(){};f.prototype=new d,i.extend(f.prototype,{toRaw:function(e){var t=e.trim().split("@");return 2===t.length&&i.all(t)?e:void 0}});var v=h.CellEditor=n.View.extend({initialize:function(e){h.requireOptions(e,["formatter","column","model"]),this.formatter=e.formatter,this.column=e.column,this.column instanceof T||(this.column=new T(this.column)),this.listenTo(this.model,"backgrid:editing",this.postRender)},postRender:function(e,t){return(null==t||t.get("name")==this.column.get("name"))&&this.$el.focus(),this}}),g=h.InputCellEditor=v.extend({tagName:"input",attributes:{type:"text"},events:{blur:"saveOrCancel",keydown:"saveOrCancel"},initialize:function(e){v.prototype.initialize.apply(this,arguments),e.placeholder&&this.$el.attr("placeholder",e.placeholder)},render:function(){return this.$el.val(this.formatter.fromRaw(this.model.get(this.column.get("name")))),this},saveOrCancel:function(e){var t=this.formatter,n=this.model,r=this.column,o=new c(e),s="blur"===e.type;if(o.moveUp()||o.moveDown()||o.moveLeft()||o.moveRight()||o.save()||s){e.preventDefault(),e.stopPropagation();var l=this.$el.val(),a=t.toRaw(l);i.isUndefined(a)?n.trigger("backgrid:error",n,r,l):(n.set(r.get("name"),a),n.trigger("backgrid:edited",n,r,o))}else o.cancel()&&(e.stopPropagation(),n.trigger("backgrid:edited",n,r,o))},postRender:function(e,t){if(null==t||t.get("name")==this.column.get("name"))if("right"===this.$el.css("text-align")){var i=this.$el.val();this.$el.focus().val(null).val(i)}else this.$el.focus();return this}}),w=h.Cell=n.View.extend({tagName:"td",formatter:new d,editor:g,events:{click:"enterEditMode"},initialize:function(e){h.requireOptions(e,["model","column"]),this.column=e.column,this.column instanceof T||(this.column=new T(this.column)),this.formatter=h.resolveNameToClass(this.column.get("formatter")||this.formatter,"Formatter"),this.editor=h.resolveNameToClass(this.editor,"CellEditor"),this.listenTo(this.model,"change:"+this.column.get("name"),function(){this.$el.hasClass("editor")||this.render()})},render:function(){return this.$el.empty(),this.$el.text(this.formatter.fromRaw(this.model.get(this.column.get("name")))),this.delegateEvents(),this},enterEditMode:function(){var e=this.model,t=this.column;t.get("editable")&&(this.currentEditor=new this.editor({column:this.column,model:this.model,formatter:this.formatter}),e.trigger("backgrid:edit",e,t,this,this.currentEditor),this.listenTo(e,"backgrid:error",this.renderError),this.undelegateEvents(),this.$el.empty(),this.$el.append(this.currentEditor.$el),this.currentEditor.render(),this.$el.addClass("editor"),e.trigger("backgrid:editing",e,t,this,this.currentEditor))},renderError:function(e,t){(null==t||t.get("name")==this.column.get("name"))&&this.$el.addClass("error")},exitEditMode:function(){this.$el.removeClass("error"),this.currentEditor.remove(),this.stopListening(this.currentEditor),delete this.currentEditor,this.$el.removeClass("editor"),this.render()},remove:function(){return this.currentEditor&&(this.currentEditor.remove.apply(this,arguments),delete this.currentEditor),n.View.prototype.remove.apply(this,arguments)}}),y=h.StringCell=w.extend({className:"string-cell",formatter:new p});h.UriCell=w.extend({className:"uri-cell",render:function(){this.$el.empty();var e=this.formatter.fromRaw(this.model.get(this.column.get("name")));return this.$el.append(t("",{tabIndex:-1,href:e,title:e,target:"_blank"}).text(e)),this.delegateEvents(),this}}),h.EmailCell=y.extend({className:"email-cell",formatter:new f,render:function(){this.$el.empty();var e=this.formatter.fromRaw(this.model.get(this.column.get("name")));return this.$el.append(t("",{tabIndex:-1,href:"mailto:"+e,title:e}).text(e)),this.delegateEvents(),this}});var C=h.NumberCell=w.extend({className:"number-cell",decimals:u.prototype.defaults.decimals,decimalSeparator:u.prototype.defaults.decimalSeparator,orderSeparator:u.prototype.defaults.orderSeparator,formatter:u,initialize:function(){w.prototype.initialize.apply(this,arguments),this.formatter=new this.formatter({decimals:this.decimals,decimalSeparator:this.decimalSeparator,orderSeparator:this.orderSeparator})}});h.IntegerCell=C.extend({className:"integer-cell",decimals:0});var b=h.DatetimeCell=w.extend({className:"datetime-cell",includeDate:m.prototype.defaults.includeDate,includeTime:m.prototype.defaults.includeTime,includeMilli:m.prototype.defaults.includeMilli,formatter:m,initialize:function(){w.prototype.initialize.apply(this,arguments),this.formatter=new this.formatter({includeDate:this.includeDate,includeTime:this.includeTime,includeMilli:this.includeMilli});var e=this.includeDate?"YYYY-MM-DD":"";e+=this.includeDate&&this.includeTime?"T":"",e+=this.includeTime?"HH:mm:ss":"",e+=this.includeTime&&this.includeMilli?".SSS":"",this.editor=this.editor.extend({attributes:i.extend({},this.editor.prototype.attributes,this.editor.attributes,{placeholder:e})})}});h.DateCell=b.extend({className:"date-cell",includeTime:!1}),h.TimeCell=b.extend({className:"time-cell",includeDate:!1});var E=h.BooleanCellEditor=v.extend({tagName:"input",attributes:{tabIndex:-1,type:"checkbox"},events:{mousedown:function(){this.mouseDown=!0},blur:"enterOrExitEditMode",mouseup:function(){this.mouseDown=!1},change:"saveOrCancel",keydown:"saveOrCancel"},render:function(){var e=this.formatter.fromRaw(this.model.get(this.column.get("name")));return this.$el.prop("checked",e),this},enterOrExitEditMode:function(e){if(!this.mouseDown){var t=this.model;t.trigger("backgrid:edited",t,this.column,new c(e))}},saveOrCancel:function(e){var t=this.model,i=this.column,n=this.formatter,r=new c(e);if(r.passThru()&&"change"!=e.type)return!0;r.cancel()&&(e.stopPropagation(),t.trigger("backgrid:edited",t,i,r));var o=this.$el;if(r.save()||r.moveLeft()||r.moveRight()||r.moveUp()||r.moveDown()){e.preventDefault(),e.stopPropagation();var s=n.toRaw(o.prop("checked"));t.set(i.get("name"),s),t.trigger("backgrid:edited",t,i,r)}else if("change"==e.type){var s=n.toRaw(o.prop("checked"));t.set(i.get("name"),s),o.focus()}}});h.BooleanCell=w.extend({className:"boolean-cell",editor:E,events:{click:"enterEditMode"},render:function(){return this.$el.empty(),this.$el.append(t("",{tabIndex:-1,type:"checkbox",checked:this.formatter.fromRaw(this.model.get(this.column.get("name")))})),this.delegateEvents(),this}});var x=h.SelectCellEditor=v.extend({tagName:"select",events:{change:"save",blur:"close",keydown:"close"},template:i.template(''),setOptionValues:function(e){this.optionValues=e},_renderOptions:function(e,t){for(var i="",n=0;e.length>n;n++)i+=this.template({text:e[n][0],value:e[n][1],selected:t==e[n][1]});return i},render:function(){this.$el.empty();var e=i.result(this,"optionValues"),n=this.model.get(this.column.get("name"));if(!i.isArray(e))throw TypeError("optionValues must be an array");for(var r=null,o=null,r=null,s=null,l=null,a=0;e.length>a;a++){var r=e[a];if(i.isArray(r))o=r[0],r=r[1],this.$el.append(this.template({text:o,value:r,selected:r==n}));else{if(!i.isObject(r))throw TypeError("optionValues elements must be a name-value pair or an object hash of { name: 'optgroup label', value: [option name-value pairs] }");s=r.name,l=t("",{label:s}),l.append(this._renderOptions(r.values,n)),this.$el.append(l)}}return this.delegateEvents(),this},save:function(e){var t=this.model,i=this.column;t.set(i.get("name"),this.formatter.toRaw(this.$el.val())),t.trigger("backgrid:edited",t,i,new c(e))},close:function(e){var t=this.model,i=this.column,n=new c(e);n.cancel()?(e.stopPropagation(),t.trigger("backgrid:edited",t,i,new c(e))):(n.save()||n.moveLeft()||n.moveRight()||n.moveUp()||n.moveDown()||"blur"==e.type)&&(e.preventDefault(),e.stopPropagation(),t.trigger("backgrid:edited",t,i,new c(e)))}});h.SelectCell=w.extend({className:"select-cell",editor:x,optionValues:void 0,initialize:function(){w.prototype.initialize.apply(this,arguments),h.requireOptions(this,["optionValues"]),this.optionValues=i.result(this,"optionValues"),this.listenTo(this.model,"backgrid:edit",function(e,t,i,n){t.get("name")==this.column.get("name")&&n.setOptionValues(this.optionValues)})},render:function(){this.$el.empty();var e=this.optionValues,t=this.formatter.fromRaw(this.model.get(this.column.get("name")));try{if(!i.isArray(e)||i.isEmpty(e))throw new TypeError;for(var n=0;e.length>n;n++){var r=e[n];if(i.isArray(r)){var o=r[0],r=r[1];if(r==t){this.$el.append(o);break}}else{if(!i.isObject(r))throw new TypeError;for(var s=r.values,l=0;s.length>l;l++){var a=s[l];if(a[1]==t){this.$el.append(a[0]);break}}}}}catch(h){if(h instanceof TypeError)throw TypeError("'optionValues' must be of type {Array.|Array.<{name: string, values: Array.}>}");throw h}return this.delegateEvents(),this}});var T=h.Column=n.Model.extend({defaults:{name:void 0,label:void 0,sortable:!0,editable:!0,renderable:!0,formatter:void 0,cell:void 0,headerCell:void 0},initialize:function(e){h.requireOptions(e,["cell","name"]),this.has("label")||this.set({label:this.get("name")},{silent:!0});var t=h.resolveNameToClass(this.get("headerCell"),"HeaderCell"),i=h.resolveNameToClass(this.get("cell"),"Cell");this.set({cell:i,headerCell:t},{silent:!0})}}),R=h.Columns=n.Collection.extend({model:T}),$=h.Row=n.View.extend({tagName:"tr",requiredOptions:["columns","model"],initialize:function(e){h.requireOptions(e,this.requiredOptions);var t=this.columns=e.columns;t instanceof n.Collection||(t=this.columns=new R(t));for(var i=this.cells=[],r=0;t.length>r;r++)i.push(this.makeCell(t.at(r),e));this.listenTo(t,"change:renderable",function(e,t){for(var n=0;i.length>n;n++){var r=i[n];r.column.get("name")==e.get("name")&&(t?r.$el.show():r.$el.hide())}}),this.listenTo(t,"add",function(t,n){var r=n.indexOf(t),o=this.makeCell(t,e);i.splice(r,0,o),o.column.get("renderable")||o.$el.hide();var s=this.$el;0===r?s.prepend(o.render().$el):r===n.length-1?s.append(o.render().$el):s.children().eq(r).before(o.render().$el)}),this.listenTo(t,"remove",function(e,t,n){i[n.index].remove(),i.splice(n.index,1)})},makeCell:function(e){return new(e.get("cell"))({column:e,model:this.model})},render:function(){this.$el.empty();for(var e=document.createDocumentFragment(),t=0;this.cells.length>t;t++){var i=this.cells[t];e.appendChild(i.render().el),i.column.get("renderable")||i.$el.hide()}return this.el.appendChild(e),this.delegateEvents(),this},remove:function(){for(var e=0;this.cells.length>e;e++){var t=this.cells[e];t.remove.apply(t,arguments)}return n.View.prototype.remove.apply(this,arguments)}}),k=h.EmptyRow=n.View.extend({tagName:"tr",emptyText:null,initialize:function(e){h.requireOptions(e,["emptyText","columns"]),this.emptyText=e.emptyText,this.columns=e.columns},render:function(){this.$el.empty();var e=document.createElement("td");return e.setAttribute("colspan",this.columns.length),e.textContent=this.emptyText,this.el.setAttribute("class","empty"),this.el.appendChild(e),this}}),D=h.HeaderCell=n.View.extend({tagName:"th",events:{"click a":"onClick"},_direction:null,initialize:function(e){h.requireOptions(e,["column","collection"]),this.column=e.column,this.column instanceof T||(this.column=new T(this.column)),this.listenTo(this.collection,"backgrid:sort",this._resetCellDirection)},direction:function(e){return arguments.length&&(this._direction&&this.$el.removeClass(this._direction),e&&this.$el.addClass(e),this._direction=e),this._direction},_resetCellDirection:function(e,t,i,n){n==this.collection&&(e!==this.column.get("name")?this.direction(null):this.direction(t))},onClick:function(e){e.preventDefault();var t=this.column.get("name");this.column.get("sortable")&&("ascending"===this.direction()?this.sort(t,"descending",function(e,i){var n=e.get(t),r=i.get(t);return n===r?0:n>r?-1:1}):"descending"===this.direction()?this.sort(t,null):this.sort(t,"ascending",function(e,i){var n=e.get(t),r=i.get(t);return n===r?0:r>n?-1:1}))},sort:function(e,t,i){i=i||this._cidComparator;var r=this.collection;if(n.PageableCollection&&r instanceof n.PageableCollection){var o;o="ascending"===t?-1:"descending"===t?1:null,r.setSorting(o?e:null,o),"client"==r.mode?(r.fullCollection.comparator||(r.fullCollection.comparator=i),r.fullCollection.sort()):r.fetch({reset:!0})}else r.comparator=i,r.sort();this.collection.trigger("backgrid:sort",e,t,i,this.collection)},_cidComparator:function(e,t){var n=e.cid,r=t.cid;if(!i.isUndefined(n)&&!i.isUndefined(r)){if(n=1*n.slice(1),r=1*r.slice(1),r>n)return-1;if(n>r)return 1}return 0},render:function(){this.$el.empty();var e=t("").text(this.column.get("label")).append("");return this.$el.append(e),this.delegateEvents(),this}});h.HeaderRow=h.Row.extend({requiredOptions:["columns","collection"],initialize:function(){h.Row.prototype.initialize.apply(this,arguments)},makeCell:function(e,t){var i=e.get("headerCell")||t.headerCell||D;return i=new i({column:e,collection:this.collection})}});var N=h.Header=n.View.extend({tagName:"thead",initialize:function(e){h.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new R(this.columns)),this.row=new h.HeaderRow({columns:this.columns,collection:this.collection})},render:function(){return this.$el.append(this.row.render().$el),this.delegateEvents(),this},remove:function(){return this.row.remove.apply(this.row,arguments),n.View.prototype.remove.apply(this,arguments)}}),O=h.Body=n.View.extend({tagName:"tbody",initialize:function(e){h.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new R(this.columns)),this.row=e.row||$,this.rows=this.collection.map(function(e){var t=new this.row({columns:this.columns,model:e});return t},this),this.emptyText=e.emptyText,this._unshiftEmptyRowMayBe();var t=this.collection;this.listenTo(t,"add",this.insertRow),this.listenTo(t,"remove",this.removeRow),this.listenTo(t,"sort",this.refresh),this.listenTo(t,"reset",this.refresh),this.listenTo(t,"backgrid:edited",this.moveToNextCell)},_unshiftEmptyRowMayBe:function(){0===this.rows.length&&null!=this.emptyText&&this.rows.unshift(new k({emptyText:this.emptyText,columns:this.columns}))},insertRow:function(e,t,r){if(this.rows[0]instanceof k&&this.rows.pop().remove(),!(t instanceof n.Collection||r))return this.collection.add(e,r=t),void 0;r=i.extend({render:!0},r||{});var o=new this.row({columns:this.columns,model:e}),s=t.indexOf(e);this.rows.splice(s,0,o);var l=this.$el,a=l.children(),h=o.render().$el;r.render&&(s>=a.length?l.append(h):a.eq(s).before(h))},removeRow:function(e,t,n){return n?((i.isUndefined(n.render)||n.render)&&this.rows[n.index].remove(),this.rows.splice(n.index,1),this._unshiftEmptyRowMayBe(),void 0):(this.collection.remove(e,n=t),this._unshiftEmptyRowMayBe(),void 0)},refresh:function(){for(var e=0;this.rows.length>e;e++)this.rows[e].remove();return this.rows=this.collection.map(function(e){var t=new this.row({columns:this.columns,model:e});return t},this),this._unshiftEmptyRowMayBe(),this.render(),this.collection.trigger("backgrid:refresh",this),this},render:function(){this.$el.empty();for(var e=document.createDocumentFragment(),t=0;this.rows.length>t;t++){var i=this.rows[t];e.appendChild(i.render().el)}return this.el.appendChild(e),this.delegateEvents(),this},remove:function(){for(var e=0;this.rows.length>e;e++){var t=this.rows[e];t.remove.apply(t,arguments)}return n.View.prototype.remove.apply(this,arguments)},moveToNextCell:function(e,t,i){var n=this.collection.indexOf(e),r=this.columns.indexOf(t);if(i.moveUp()||i.moveDown()||i.moveLeft()||i.moveRight()||i.save()){var o=this.columns.length,s=o*this.collection.length;if(i.moveUp()||i.moveDown()){var l=this.rows[n+(i.moveUp()?-1:1)];l&&l.cells[r].enterEditMode()}else if(i.moveLeft()||i.moveRight())for(var a=i.moveRight(),h=n*o+r+(a?1:-1);h>=0&&s>h;a?h++:h--){var c=~~(h/o),d=h-c*o,u=this.rows[c].cells[d];if(u.column.get("renderable")&&u.column.get("editable")){u.enterEditMode();break}}}this.rows[n].cells[r].exitEditMode()}});h.Footer=n.View.extend({tagName:"tfoot",initialize:function(e){h.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new h.Columns(this.columns))}}),h.Grid=n.View.extend({tagName:"table",className:"backgrid",header:N,body:O,footer:null,initialize:function(e){h.requireOptions(e,["columns","collection"]),e.columns instanceof n.Collection||(e.columns=new R(e.columns)),this.columns=e.columns;var t=i.omit(e,["el","id","attributes","className","tagName","events"]);this.header=e.header||this.header,this.header=new this.header(t),this.body=e.body||this.body,this.body=new this.body(t),this.footer=e.footer||this.footer,this.footer&&(this.footer=new this.footer(t)),this.listenTo(this.columns,"reset",function(){this.header=new(this.header.remove().constructor)(t),this.body=new(this.body.remove().constructor)(t),this.footer&&(this.footer=new(this.footer.remove().constructor)(t)),this.render()})},insertRow:function(e,t,i){return this.body.insertRow(e,t,i)},removeRow:function(e,t,i){return this.body.removeRow(e,t,i)},insertColumn:function(e,t){return t=t||{render:!0},this.columns.add(e,t),this},removeColumn:function(e,t){return this.columns.remove(e,t),this},render:function(){return this.$el.empty(),this.$el.append(this.header.render().$el),this.footer&&this.$el.append(this.footer.render().$el),this.$el.append(this.body.render().$el),this.delegateEvents(),this.trigger("backgrid:rendered",this),this},remove:function(){return this.header.remove.apply(this.header,arguments),this.body.remove.apply(this.body,arguments),this.footer&&this.footer.remove.apply(this.footer,arguments),n.View.prototype.remove.apply(this,arguments)}})})(this,jQuery,_,Backbone); \ No newline at end of file +(function(e,t,i,n){"use strict";function r(e){return String.fromCharCode(e.charCodeAt(0)-32)+e.slice(1)}function o(e,t,i){var n=t-(e+"").length;n=0>n?0:n;for(var r="",o=0;n>o;o++)r+=i;return r+e}var s=e,l=" \n \f\r   ᠎              \u2028\u2029";if(!String.prototype.trim||l.trim()){l="["+l+"]";var a=RegExp("^"+l+l+"*"),h=RegExp(l+l+"*$");String.prototype.trim=function(){if(void 0===this||null===this)throw new TypeError("can't convert "+this+" to object");return(this+"").replace(a,"").replace(h,"")}}var c=e.Backgrid={VERSION:"0.2.5",Extension:{},requireOptions:function(e,t){for(var n=0;t.length>n;n++){var r=t[n];if(i.isUndefined(e[r]))throw new TypeError("'"+r+"' is required")}},resolveNameToClass:function(e,t){if(i.isString(e)){var n=i.map(e.split("-"),function(e){return r(e)}).join("")+t,o=c[n]||c.Extension[n];if(i.isUndefined(o))throw new ReferenceError("Class '"+n+"' not found");return o}return e}};i.extend(c,n.Events);var d=c.Command=function(e){i.extend(this,{altKey:!!e.altKey,"char":e.char,charCode:e.charCode,ctrlKey:!!e.ctrlKey,key:e.key,keyCode:e.keyCode,locale:e.locale,location:e.location,metaKey:!!e.metaKey,repeat:!!e.repeat,shiftKey:!!e.shiftKey,which:e.which})};i.extend(d.prototype,{moveUp:function(){return 38==this.keyCode},moveDown:function(){return 40===this.keyCode},moveLeft:function(){return this.shiftKey&&9===this.keyCode},moveRight:function(){return!this.shiftKey&&9===this.keyCode},save:function(){return 13===this.keyCode},cancel:function(){return 27===this.keyCode},passThru:function(){return!(this.moveUp()||this.moveDown()||this.moveLeft()||this.moveRight()||this.save()||this.cancel())}});var u=["model","collection","el","id","attributes","className","tagName","events"],m=c.View=function(e){this.cid=i.uniqueId("view"),this.options=e=e||{},i.extend(this,i.pick(e,u)),this._ensureElement(e),this.initialize.apply(this,arguments),this.delegateEvents()},f=/^(\S+)\s*(.*)$/;i.extend(m.prototype,n.Events,{use$:!1,tagName:"div",$:function(e){return this.$el?this.$el.find(e):this.el.querySelectorAll(e)},initialize:function(){},render:function(){return this},empty:function(){if(this.$el)this.$el.remove();else for(var e=this.el;e.hasChildNodes();)e.removeChild(e.firstChild);return this},remove:function(){return this.empty(),this.stopListening(),this},setElement:function(e,t){t=i.extend({use$:n.$&&this.use$,delegate:!0},t||{});var r=t.delegate;return this.el&&this.undelegateEvents(),this.el=e,t.use$&&(this.$el=n.$(e)),r!==!1&&this.delegateEvents(),this},_processEvents:function(e,t){for(var n in e){var r=e[n];if(i.isFunction(r)||(r=this[e[n]]),r){r=i.bind(r,this);var o=n.match(f);t(o[1],o[2],r)}}},delegateEvents:function(e){if(!e&&!(e=i.result(this,"events")))return this;this.undelegateEvents();var t=this.el,n=this.$el,r=this.cid;return this._processEvents(e,function(e,i,o){var s=e+".delegateEvents"+r;if(""===i)n?n.on(s,o):t.addEventListener?t.addEventListener(e,o):t.attachEvent&&t.attachEvent("on"+e,o);else if(n)n.on(s,i,o);else for(var l=t.querySelectorAll(i),a=0,h=l.length;h>a;a++){var c=l[a];t.addEventListener?c.addEventListener(e,o):t.attachEvent&&c.attachEvent("on"+e,o)}}),this},undelegateEvents:function(){var e=i.result(this,"events");if(!e)return this;if(this.$el)this.$el.off(".delegateEvents"+this.cid);else{var t=this.el;this._processEvents(e,function(e,i,n){if(""===i)t.removeEventListener&&t.removeEventListener(e,n),t.detachEvent&&t.detachEvent("on"+e,n);else for(var r=t.querySelectorAll(i),o=0,s=r.length;s>o;o++){var l=r[o];t.removeEventListener?l.removeEventListener(e,n):t.detachEvent&&l.detachEvent("on"+e,n)}})}return this},_ensureElement:function(e){if(e=i.extend(e,{delegate:!1}),this.el)this.setElement(i.result(this,"el"),e);else{var t=this.el=s.document.createElement(this.tagName),n=i.extend({},i.result(this,"attributes"));this.id&&(n.id=i.result(this,"id")),this.className&&(n["class"]=i.result(this,"className"));for(var r in n)t.setAttribute(r,n[r]);this.setElement(t,e)}}}),m.extend=n.View.extend;var p=c.CellFormatter=function(){};i.extend(p.prototype,{fromRaw:function(e){return e},toRaw:function(e){return e}});var v=c.NumberFormatter=function(e){if(e=e?i.clone(e):{},i.extend(this,this.defaults,e),0>this.decimals||this.decimals>20)throw new RangeError("decimals must be between 0 and 20")};v.prototype=new p,i.extend(v.prototype,{defaults:{decimals:2,decimalSeparator:".",orderSeparator:","},HUMANIZED_NUM_RE:/(\d)(?=(?:\d{3})+$)/g,fromRaw:function(e){if(i.isNull(e)||i.isUndefined(e))return"";e=e.toFixed(~~this.decimals);var t=e.split("."),n=t[0],r=t[1]?(this.decimalSeparator||".")+t[1]:"";return n.replace(this.HUMANIZED_NUM_RE,"$1"+this.orderSeparator)+r},toRaw:function(e){for(var t="",n=e.trim().split(this.orderSeparator),r=0;n.length>r;r++)t+=n[r];var o=t.split(this.decimalSeparator);t="";for(var r=0;o.length>r;r++)t=t+o[r]+".";"."===t[t.length-1]&&(t=t.slice(0,t.length-1));var s=1*(1*t).toFixed(~~this.decimals);return i.isNumber(s)&&!i.isNaN(s)?s:void 0}});var g=c.DatetimeFormatter=function(e){if(e=e?i.clone(e):{},i.extend(this,this.defaults,e),!this.includeDate&&!this.includeTime)throw Error("Either includeDate or includeTime must be true")};g.prototype=new p,i.extend(g.prototype,{defaults:{includeDate:!0,includeTime:!0,includeMilli:!1},DATE_RE:/^([+\-]?\d{4})-(\d{2})-(\d{2})$/,TIME_RE:/^(\d{2}):(\d{2}):(\d{2})(\.(\d{3}))?$/,ISO_SPLITTER_RE:/T|Z| +/,_convert:function(e,t){e=e.trim();var n=e.split(this.ISO_SPLITTER_RE)||[],r=this.DATE_RE.test(n[0])?n[0]:"",s=r&&n[1]?n[1]:this.TIME_RE.test(n[0])?n[0]:"",l=this.DATE_RE.exec(r)||[],a=this.TIME_RE.exec(s)||[];if(t){if(this.includeDate&&i.isUndefined(l[0]))return;if(this.includeTime&&i.isUndefined(a[0]))return;if(!this.includeDate&&r)return;if(!this.includeTime&&s)return}var h=new Date(Date.UTC(1*l[1]||0,1*l[2]-1||0,1*l[3]||0,1*a[1]||null,1*a[2]||null,1*a[3]||null,1*a[5]||null)),c="";return this.includeDate&&(c=o(h.getUTCFullYear(),4,0)+"-"+o(h.getUTCMonth()+1,2,0)+"-"+o(h.getUTCDate(),2,0)),this.includeTime&&(c=c+(this.includeDate?"T":"")+o(h.getUTCHours(),2,0)+":"+o(h.getUTCMinutes(),2,0)+":"+o(h.getUTCSeconds(),2,0),this.includeMilli&&(c=c+"."+o(h.getUTCMilliseconds(),3,0))),this.includeDate&&this.includeTime&&(c+="Z"),c},fromRaw:function(e){return i.isNull(e)||i.isUndefined(e)?"":this._convert(e)},toRaw:function(e){return this._convert(e,!0)}});var y=c.StringFormatter=function(){};y.prototype=new p,i.extend(y.prototype,{fromRaw:function(e){return i.isUndefined(e)||i.isNull(e)?"":e+""}});var w=c.EmailFormatter=function(){};w.prototype=new p,i.extend(w.prototype,{toRaw:function(e){var t=e.trim().split("@");return 2===t.length&&i.all(t)?e:void 0}});var E=c.CellEditor=c.View.extend({initialize:function(e){c.requireOptions(e,["formatter","column","model"]),this.formatter=e.formatter,this.column=e.column,this.column instanceof D||(this.column=new D(this.column)),this.listenTo(this.model,"backgrid:editing",this.postRender)},postRender:function(e,t){return(null==t||t.get("name")==this.column.get("name"))&&this.el.focus(),this}}),C=c.InputCellEditor=E.extend({tagName:"input",attributes:{type:"text"},events:{blur:"saveOrCancel",keydown:"saveOrCancel"},initialize:function(e){E.prototype.initialize.apply(this,arguments),e.placeholder&&this.el.setAttribute("placeholder",e.placeholder)},render:function(){return this.el.value=this.formatter.fromRaw(this.model.get(this.column.get("name"))),this},saveOrCancel:function(e){var t=this.formatter,n=this.model,r=this.column,o=new d(e),s="blur"===e.type;if(o.moveUp()||o.moveDown()||o.moveLeft()||o.moveRight()||o.save()||s){e.preventDefault(),e.stopPropagation();var l=this.el.value,a=t.toRaw(l);i.isUndefined(a)?n.trigger("backgrid:error",n,r,l):(n.set(r.get("name"),a),n.trigger("backgrid:edited",n,r,o))}else o.cancel()&&(e.stopPropagation(),n.trigger("backgrid:edited",n,r,o))},postRender:function(e,t){if(null==t||t.get("name")==this.column.get("name")){var i,n=this.el;if(s.getComputedStyle?i=s.getComputedStyle(n).textAlign:n.currentStyle&&(i=n.currentStyle.textAlign),"right"===i){var r=n.value;n.focus(),n.val=null,n.val=r}else n.focus()}return this}}),b=c.Cell=c.View.extend({tagName:"td",formatter:new p,editor:C,events:{click:"enterEditMode"},initialize:function(e){c.requireOptions(e,["model","column"]),this.column=e.column,this.column instanceof D||(this.column=new D(this.column)),this.formatter=c.resolveNameToClass(this.column.get("formatter")||this.formatter,"Formatter"),this.editor=c.resolveNameToClass(this.editor,"CellEditor"),this.listenTo(this.model,"change:"+this.column.get("name"),function(){this.el.classList.contains("editor")||this.render()})},show:function(){return this.el.style.display="",this},hide:function(){return this.el.style.display="none",this},render:function(){return this.empty(),this.el.appendChild(s.document.createTextNode(this.formatter.fromRaw(this.model.get(this.column.get("name"))))),this.delegateEvents(),this},enterEditMode:function(){var e=this.model,t=this.column;t.get("editable")&&(this.currentEditor=new this.editor({column:this.column,model:this.model,formatter:this.formatter}),e.trigger("backgrid:edit",e,t,this,this.currentEditor),this.listenTo(e,"backgrid:error",this.renderError),this.undelegateEvents(),this.empty(),this.el.appendChild(this.currentEditor.el),this.currentEditor.render(),this.el.classList.add("editor"),e.trigger("backgrid:editing",e,t,this,this.currentEditor))},renderError:function(e,t){(null==t||t.get("name")==this.column.get("name"))&&this.el.classList.add("error")},exitEditMode:function(){this.el.classList.remove("error"),this.currentEditor.remove(),this.stopListening(this.currentEditor),delete this.currentEditor,this.el.classList.remove("editor"),this.render()},remove:function(){return this.currentEditor&&(this.currentEditor.remove.apply(this,arguments),delete this.currentEditor),c.View.prototype.remove.apply(this,arguments)}}),x=c.StringCell=b.extend({className:"string-cell",formatter:new y});c.UriCell=b.extend({className:"uri-cell",render:function(){this.empty();var e=this.formatter.fromRaw(this.model.get(this.column.get("name"))),t=s.document,i=t.createElement("a");return i.tabIndex=-1,i.href=e,i.title=e,i.target="_blank",i.appendChild(t.createTextNode(e)),this.el.appendChild(i),this.delegateEvents(),this}}),c.EmailCell=x.extend({className:"email-cell",formatter:new w,render:function(){this.empty();var e=this.formatter.fromRaw(this.model.get(this.column.get("name"))),t=s.document,i=t.createElement("a");return i.tabIndex=-1,i.href="mailto:"+e,i.title=e,i.appendChild(t.createTextNode(e)),this.el.appendChild(i),this.delegateEvents(),this}});var T=c.NumberCell=b.extend({className:"number-cell",decimals:v.prototype.defaults.decimals,decimalSeparator:v.prototype.defaults.decimalSeparator,orderSeparator:v.prototype.defaults.orderSeparator,formatter:v,initialize:function(){b.prototype.initialize.apply(this,arguments),this.formatter=new this.formatter({decimals:this.decimals,decimalSeparator:this.decimalSeparator,orderSeparator:this.orderSeparator})}});c.IntegerCell=T.extend({className:"integer-cell",decimals:0});var R=c.DatetimeCell=b.extend({className:"datetime-cell",includeDate:g.prototype.defaults.includeDate,includeTime:g.prototype.defaults.includeTime,includeMilli:g.prototype.defaults.includeMilli,formatter:g,initialize:function(){b.prototype.initialize.apply(this,arguments),this.formatter=new this.formatter({includeDate:this.includeDate,includeTime:this.includeTime,includeMilli:this.includeMilli});var e=this.includeDate?"YYYY-MM-DD":"";e+=this.includeDate&&this.includeTime?"T":"",e+=this.includeTime?"HH:mm:ss":"",e+=this.includeTime&&this.includeMilli?".SSS":"",this.editor=this.editor.extend({attributes:i.extend({},this.editor.prototype.attributes,this.editor.attributes,{placeholder:e})})}});c.DateCell=R.extend({className:"date-cell",includeTime:!1}),c.TimeCell=R.extend({className:"time-cell",includeDate:!1});var N=c.BooleanCellEditor=E.extend({tagName:"input",attributes:{tabIndex:-1,type:"checkbox"},events:{mousedown:function(){this.mouseDown=!0},blur:"enterOrExitEditMode",mouseup:function(){this.mouseDown=!1},change:"saveOrCancel",keydown:"saveOrCancel"},render:function(){var e=this.formatter.fromRaw(this.model.get(this.column.get("name")));return this.el.checked=e,this},enterOrExitEditMode:function(e){if(!this.mouseDown){var t=this.model;t.trigger("backgrid:edited",t,this.column,new d(e))}},saveOrCancel:function(e){var t=this.model,i=this.column,n=this.formatter,r=new d(e);if(r.passThru()&&"change"!=e.type)return!0;r.cancel()&&(e.stopPropagation(),t.trigger("backgrid:edited",t,i,r));var o=this.el;if(r.save()||r.moveLeft()||r.moveRight()||r.moveUp()||r.moveDown()){e.preventDefault(),e.stopPropagation();var s=n.toRaw(o.checked);t.set(i.get("name"),s),t.trigger("backgrid:edited",t,i,r)}else if("change"==e.type){var s=n.toRaw(o.checked);t.set(i.get("name"),s),o.focus()}}});c.BooleanCell=b.extend({className:"boolean-cell",editor:N,events:{click:"enterEditMode"},render:function(){this.empty();var e=s.document.createElement("input");return e.tabIndex=-1,e.type="checkbox",e.checked=this.formatter.fromRaw(this.model.get(this.column.get("name"))),this.el.appendChild(e),this.delegateEvents(),this}});var k=c.SelectCellEditor=E.extend({tagName:"select",events:{change:"save",blur:"close",keydown:"close"},template:i.template(''),setOptionValues:function(e){this.optionValues=e},_renderOptions:function(e,t){for(var i="",n=0;e.length>n;n++)i+=this.template({text:e[n][0],value:e[n][1],selected:t==e[n][1]});return i},render:function(){this.empty();var e=i.result(this,"optionValues"),t=this.model.get(this.column.get("name"));if(!i.isArray(e))throw TypeError("optionValues must be an array");for(var n=null,r=null,n=null,o=null,s=null,l="",a=0;e.length>a;a++){var n=e[a];if(i.isArray(n))r=n[0],n=n[1],l+=this.template({text:r,value:n,selected:n==t});else{if(!i.isObject(n))throw TypeError("optionValues elements must be a name-value pair or an object hash of { name: 'optgroup label', value: [option name-value pairs] }");o=n.name,s=this._renderOptions(n.values,t),l=l+''+s+""}}return this.el.innerHTML=l,this.delegateEvents(),this},save:function(e){var t=this.model,i=this.column;t.set(i.get("name"),this.formatter.toRaw(this.el.value)),t.trigger("backgrid:edited",t,i,new d(e))},close:function(e){var t=this.model,i=this.column,n=new d(e);n.cancel()?(e.stopPropagation(),t.trigger("backgrid:edited",t,i,new d(e))):(n.save()||n.moveLeft()||n.moveRight()||n.moveUp()||n.moveDown()||"blur"==e.type)&&(e.preventDefault(),e.stopPropagation(),t.trigger("backgrid:edited",t,i,new d(e)))}});c.SelectCell=b.extend({className:"select-cell",editor:k,optionValues:void 0,initialize:function(){b.prototype.initialize.apply(this,arguments),c.requireOptions(this,["optionValues"]),this.optionValues=i.result(this,"optionValues"),this.listenTo(this.model,"backgrid:edit",function(e,t,i,n){t.get("name")==this.column.get("name")&&n.setOptionValues(this.optionValues)})},render:function(){this.empty();var e=this.optionValues,t=this.formatter.fromRaw(this.model.get(this.column.get("name")));try{if(!i.isArray(e)||i.isEmpty(e))throw new TypeError;for(var n=s.document,r=0;e.length>r;r++){var o=e[r];if(i.isArray(o)){var l=o[0],o=o[1];if(o==t){this.el.appendChild(n.createTextNode(l));break}}else{if(!i.isObject(o))throw new TypeError;for(var a=o.values,h=0;a.length>h;h++){var c=a[h];if(c[1]==t){this.el.appendChild(n.createTextNode(c[0]));break}}}}}catch(d){if(d instanceof TypeError)throw TypeError("'optionValues' must be of type {Array.|Array.<{name: string, values: Array.}>}");throw d}return this.delegateEvents(),this}});var D=c.Column=n.Model.extend({defaults:{name:void 0,label:void 0,sortable:!0,editable:!0,renderable:!0,formatter:void 0,cell:void 0,headerCell:void 0},initialize:function(e){c.requireOptions(e,["cell","name"]),this.has("label")||this.set({label:this.get("name")},{silent:!0});var t=c.resolveNameToClass(this.get("headerCell"),"HeaderCell"),i=c.resolveNameToClass(this.get("cell"),"Cell");this.set({cell:i,headerCell:t},{silent:!0})}}),S=c.Columns=n.Collection.extend({model:D}),_=c.Row=c.View.extend({tagName:"tr",requiredOptions:["columns","model"],initialize:function(e){c.requireOptions(e,this.requiredOptions);var t=this.columns=e.columns;t instanceof n.Collection||(t=this.columns=new S(t));for(var i=this.cells=[],r=0;t.length>r;r++)i.push(this.makeCell(t.at(r),e));this.listenTo(t,"change:renderable",function(e,t){for(var n=0;i.length>n;n++){var r=i[n];r.column.get("name")==e.get("name")&&(t?r.show():r.hide())}}),this.listenTo(t,"add",function(t,n){var r=n.indexOf(t),o=this.makeCell(t,e);i.splice(r,0,o),o.column.get("renderable")||o.hide();var s=this.el,l=s.childNodes();0===r?s.insertBefore(o.render().el,s.firstChild):r===n.length-1?s.appendChild(o.render().el):s.insertBefore(o.render().el,l[r])}),this.listenTo(t,"remove",function(e,t,n){i[n.index].remove(),i.splice(n.index,1)})},makeCell:function(e){return new(e.get("cell"))({column:e,model:this.model})},render:function(){this.empty();for(var e=document.createDocumentFragment(),t=0;this.cells.length>t;t++){var i=this.cells[t];e.appendChild(i.render().el),i.column.get("renderable")||i.hide()}return this.el.appendChild(e),this.delegateEvents(),this},remove:function(){for(var e=0;this.cells.length>e;e++){var t=this.cells[e];t.remove.apply(t,arguments)}return c.View.prototype.remove.apply(this,arguments)}}),O=c.EmptyRow=c.View.extend({tagName:"tr",emptyText:null,initialize:function(e){c.requireOptions(e,["emptyText","columns"]),this.emptyText=e.emptyText,this.columns=e.columns},render:function(){this.empty();var e=document.createElement("td");return e.setAttribute("colspan",this.columns.length),e.textContent=this.emptyText,this.el.setAttribute("class","empty"),this.el.appendChild(e),this}}),M=c.HeaderCell=c.View.extend({tagName:"th",events:{"click a":"onClick"},_direction:null,initialize:function(e){c.requireOptions(e,["column","collection"]),this.column=e.column,this.column instanceof D||(this.column=new D(this.column)),this.listenTo(this.collection,"backgrid:sort",this._resetCellDirection)},direction:function(e){return arguments.length&&(this._direction&&this.el.classList.remove(this._direction),e&&this.el.classList.add(e),this._direction=e),this._direction},_resetCellDirection:function(e,t,i,n){n==this.collection&&(e!==this.column.get("name")?this.direction(null):this.direction(t))},onClick:function(e){e.preventDefault();var t=this.column.get("name");this.column.get("sortable")&&("ascending"===this.direction()?this.sort(t,"descending",function(e,i){var n=e.get(t),r=i.get(t);return n===r?0:n>r?-1:1}):"descending"===this.direction()?this.sort(t,null):this.sort(t,"ascending",function(e,i){var n=e.get(t),r=i.get(t);return n===r?0:r>n?-1:1}))},sort:function(e,t,i){i=i||this._cidComparator;var r=this.collection;if(n.PageableCollection&&r instanceof n.PageableCollection){var o;o="ascending"===t?-1:"descending"===t?1:null,r.setSorting(o?e:null,o),"client"==r.mode?(r.fullCollection.comparator||(r.fullCollection.comparator=i),r.fullCollection.sort()):r.fetch({reset:!0})}else r.comparator=i,r.sort();this.collection.trigger("backgrid:sort",e,t,i,this.collection)},_cidComparator:function(e,t){var n=e.cid,r=t.cid;if(!i.isUndefined(n)&&!i.isUndefined(r)){if(n=1*n.slice(1),r=1*r.slice(1),r>n)return-1;if(n>r)return 1}return 0},render:function(){this.empty();var e=s.document,t=e.createElement("a");t.appendChild(e.createTextNode(this.column.get("label")));var i=e.createElement("b");return i.className="sort-caret",t.appendChild(i),this.el.appendChild(t),this.delegateEvents(),this}});c.HeaderRow=c.Row.extend({requiredOptions:["columns","collection"],initialize:function(){c.Row.prototype.initialize.apply(this,arguments)},makeCell:function(e,t){var i=e.get("headerCell")||t.headerCell||M;return i=new i({column:e,collection:this.collection})}});var U=c.Header=c.View.extend({tagName:"thead",initialize:function(e){c.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new S(this.columns)),this.row=new c.HeaderRow({columns:this.columns,collection:this.collection})},render:function(){return this.el.appendChild(this.row.render().el),this.delegateEvents(),this},remove:function(){return this.row.remove.apply(this.row,arguments),c.View.prototype.remove.apply(this,arguments)}}),V=c.Body=c.View.extend({tagName:"tbody",initialize:function(e){c.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new S(this.columns)),this.row=e.row||_,this.rows=this.collection.map(function(e){var t=new this.row({columns:this.columns,model:e});return t},this),this.emptyText=e.emptyText,this._unshiftEmptyRowMayBe();var t=this.collection;this.listenTo(t,"add",this.insertRow),this.listenTo(t,"remove",this.removeRow),this.listenTo(t,"sort",this.refresh),this.listenTo(t,"reset",this.refresh),this.listenTo(t,"backgrid:edited",this.moveToNextCell)},_unshiftEmptyRowMayBe:function(){0===this.rows.length&&null!=this.emptyText&&this.rows.unshift(new O({emptyText:this.emptyText,columns:this.columns}))},insertRow:function(e,t,r){if(this.rows[0]instanceof O&&this.rows.pop().remove(),!(t instanceof n.Collection||r))return this.collection.add(e,r=t),void 0;r=i.extend({render:!0},r||{});var o=new this.row({columns:this.columns,model:e}),s=t.indexOf(e);this.rows.splice(s,0,o);var l=this.el,a=l.childNodes(),h=o.render().el;r.render&&(s>=a.length?l.appendChild(h):l.insertBefore(h,a[s]))},removeRow:function(e,t,n){return n?((i.isUndefined(n.render)||n.render)&&this.rows[n.index].remove(),this.rows.splice(n.index,1),this._unshiftEmptyRowMayBe(),void 0):(this.collection.remove(e,n=t),this._unshiftEmptyRowMayBe(),void 0)},refresh:function(){for(var e=0;this.rows.length>e;e++)this.rows[e].remove();return this.rows=this.collection.map(function(e){var t=new this.row({columns:this.columns,model:e});return t},this),this._unshiftEmptyRowMayBe(),this.render(),this.collection.trigger("backgrid:refresh",this),this},render:function(){this.empty();for(var e=document.createDocumentFragment(),t=0;this.rows.length>t;t++){var i=this.rows[t];e.appendChild(i.render().el)}return this.el.appendChild(e),this.delegateEvents(),this},remove:function(){for(var e=0;this.rows.length>e;e++){var t=this.rows[e];t.remove.apply(t,arguments)}return c.View.prototype.remove.apply(this,arguments)},moveToNextCell:function(e,t,i){var n=this.collection.indexOf(e),r=this.columns.indexOf(t);if(i.moveUp()||i.moveDown()||i.moveLeft()||i.moveRight()||i.save()){var o=this.columns.length,s=o*this.collection.length;if(i.moveUp()||i.moveDown()){var l=this.rows[n+(i.moveUp()?-1:1)];l&&l.cells[r].enterEditMode()}else if(i.moveLeft()||i.moveRight())for(var a=i.moveRight(),h=n*o+r+(a?1:-1);h>=0&&s>h;a?h++:h--){var c=~~(h/o),d=h-c*o,u=this.rows[c].cells[d];if(u.column.get("renderable")&&u.column.get("editable")){u.enterEditMode();break}}}this.rows[n].cells[r].exitEditMode()}});c.Footer=c.View.extend({tagName:"tfoot",initialize:function(e){c.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new c.Columns(this.columns))}}),c.Grid=c.View.extend({tagName:"table",className:"backgrid",header:U,body:V,footer:null,initialize:function(e){c.requireOptions(e,["columns","collection"]),e.columns instanceof n.Collection||(e.columns=new S(e.columns)),this.columns=e.columns;var t=i.omit(e,["el","id","attributes","className","tagName","events"]);this.header=e.header||this.header,this.header=new this.header(t),this.body=e.body||this.body,this.body=new this.body(t),this.footer=e.footer||this.footer,this.footer&&(this.footer=new this.footer(t)),this.listenTo(this.columns,"reset",function(){this.header=new(this.header.remove().constructor)(t),this.body=new(this.body.remove().constructor)(t),this.footer&&(this.footer=new(this.footer.remove().constructor)(t)),this.render()})},insertRow:function(e,t,i){return this.body.insertRow(e,t,i)},removeRow:function(e,t,i){return this.body.removeRow(e,t,i)},insertColumn:function(e,t){return t=t||{render:!0},this.columns.add(e,t),this},removeColumn:function(e,t){return this.columns.remove(e,t),this},render:function(){return this.empty(),this.el.appendChild(this.header.render().el),this.footer&&this.el.appendChild(this.footer.render().el),this.el.appendChild(this.body.render().el),this.delegateEvents(),this.trigger("backgrid:rendered",this),this},remove:function(){return this.header.remove.apply(this.header,arguments),this.body.remove.apply(this.body,arguments),this.footer&&this.footer.remove.apply(this.footer,arguments),c.View.prototype.remove.apply(this,arguments)}})})(this,jQuery,_,Backbone); \ No newline at end of file diff --git a/lib/extensions/filter/backgrid-filter.js b/lib/extensions/filter/backgrid-filter.js index c98c6658..ce935f85 100644 --- a/lib/extensions/filter/backgrid-filter.js +++ b/lib/extensions/filter/backgrid-filter.js @@ -6,7 +6,7 @@ Licensed under the MIT @license. */ -(function ($, _, Backbone, Backgrid, lunr) { +(function (_, Backbone, Backgrid, lunr) { "use strict"; @@ -16,7 +16,7 @@ @class Backgrid.Extension.ServerSideFilter */ - var ServerSideFilter = Backgrid.Extension.ServerSideFilter = Backbone.View.extend({ + var ServerSideFilter = Backgrid.Extension.ServerSideFilter = Backgrid.View.extend({ /** @property */ tagName: "form", @@ -47,11 +47,15 @@ */ initialize: function (options) { Backgrid.requireOptions(options, ["collection"]); - Backbone.View.prototype.initialize.apply(this, arguments); + Backgrid.View.prototype.initialize.apply(this, arguments); this.name = options.name || this.name; this.placeholder = options.placeholder || this.placeholder; }, + searchBox: function () { + return this.el.querySelector("input[type=text]"); + }, + /** Upon search form submission, this event handler constructs a query parameter object and pass it to Collection#fetch for server-side @@ -59,9 +63,9 @@ */ search: function (e) { if (e) e.preventDefault(); - var $text = $(e.target).find("input[type=text]"); + var searchBox = this.searchBox(); var data = {}; - data[$text.attr("name")] = $text.val(); + data[searchBox.name] = searchBox.value; this.collection.fetch({data: data}); }, @@ -71,7 +75,7 @@ */ clear: function (e) { if (e) e.preventDefault(); - this.$("input[type=text]").val(null); + this.searchBox().value = null; this.collection.fetch(); }, @@ -80,11 +84,11 @@ a preset value if supplied during initialization. */ render: function () { - this.$el.empty().append(this.template({ + this.empty().el.innerHTML = this.template({ name: this.name, placeholder: this.placeholder, value: this.value - })); + }); this.delegateEvents(); return this; } @@ -210,7 +214,7 @@ when all the matches have been found. */ search: function () { - var matcher = _.bind(this.makeMatcher(this.$("input[type=text]").val()), this); + var matcher = _.bind(this.makeMatcher(this.searchBox().value), this); this.collection.reset(this.shadowCollection.filter(matcher), {reindex: false}); }, @@ -218,7 +222,7 @@ Clears the search box and reset the collection to its original. */ clear: function () { - this.$("input[type=text]").val(null); + this.searchBox().value = null; this.collection.reset(this.shadowCollection.models, {reindex: false}); } @@ -343,7 +347,7 @@ query answer. */ search: function () { - var searchResults = this.index.search(this.$("input[type=text]").val()); + var searchResults = this.index.search(this.searchBox().value); var models = []; for (var i = 0; i < searchResults.length; i++) { var result = searchResults[i]; @@ -354,4 +358,4 @@ }); -}(jQuery, _, Backbone, Backgrid, lunr)); +}(_, Backbone, Backgrid, lunr)); diff --git a/lib/extensions/filter/backgrid-filter.min.js b/lib/extensions/filter/backgrid-filter.min.js index f1c10a8d..0b808c81 100644 --- a/lib/extensions/filter/backgrid-filter.min.js +++ b/lib/extensions/filter/backgrid-filter.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,i,n,s){"use strict";var a=n.Extension.ServerSideFilter=i.View.extend({tagName:"form",className:"backgrid-filter form-search",template:t.template(''),events:{"click .close":"clear",submit:"search"},name:"q",placeholder:null,initialize:function(e){n.requireOptions(e,["collection"]),i.View.prototype.initialize.apply(this,arguments),this.name=e.name||this.name,this.placeholder=e.placeholder||this.placeholder},search:function(t){t&&t.preventDefault();var i=e(t.target).find("input[type=text]"),n={};n[i.attr("name")]=i.val(),this.collection.fetch({data:n})},clear:function(e){e&&e.preventDefault(),this.$("input[type=text]").val(null),this.collection.fetch()},render:function(){return this.$el.empty().append(this.template({name:this.name,placeholder:this.placeholder,value:this.value})),this.delegateEvents(),this}}),r=n.Extension.ClientSideFilter=a.extend({events:{"click .close":function(e){e.preventDefault(),this.clear()},"change input[type=text]":"search","keyup input[type=text]":"search",submit:function(e){e.preventDefault(),this.search()}},fields:null,wait:149,initialize:function(e){a.prototype.initialize.apply(this,arguments),this.fields=e.fields||this.fields,this.wait=e.wait||this.wait,this._debounceMethods(["search","clear"]);var i=this.collection,n=this.shadowCollection=i.clone();n.url=i.url,n.sync=i.sync,n.parse=i.parse,this.listenTo(i,"add",function(e,t,i){n.add(e,i)}),this.listenTo(i,"remove",function(e,t,i){n.remove(e,i)}),this.listenTo(i,"sort reset",function(e,i){i=t.extend({reindex:!0},i||{}),i.reindex&&n.reset(e.models)})},_debounceMethods:function(e){t.isString(e)&&(e=[e]),this.undelegateEvents();for(var i=0,n=e.length;n>i;i++){var s=e[i],a=this[s];this[s]=t.debounce(a,this.wait)}this.delegateEvents()},makeMatcher:function(e){var t=RegExp(e.trim().split(/\W/).join("|"),"i");return function(e){for(var i=this.fields||e.keys(),n=0,s=i.length;s>n;n++)if(t.test(e.get(i[n])+""))return!0;return!1}},search:function(){var e=t.bind(this.makeMatcher(this.$("input[type=text]").val()),this);this.collection.reset(this.shadowCollection.filter(e),{reindex:!1})},clear:function(){this.$("input[type=text]").val(null),this.collection.reset(this.shadowCollection.models,{reindex:!1})}});n.Extension.LunrFilter=r.extend({ref:"id",fields:null,initialize:function(e){r.prototype.initialize.apply(this,arguments),this.ref=e.ref||this.ref;var t=this.collection;this.listenTo(t,"add",this.addToIndex),this.listenTo(t,"remove",this.removeFromIndex),this.listenTo(t,"reset",this.resetIndex),this.listenTo(t,"change",this.updateIndex),this.resetIndex(t)},resetIndex:function(e,i){if(i=t.extend({reindex:!0},i||{}),i.reindex){var n=this;this.index=s(function(){t.each(n.fields,function(e,t){this.field(t,e),this.ref(n.ref)},this)}),e.each(function(e){this.addToIndex(e)},this)}},addToIndex:function(e){var t=this.index,i=e.toJSON();t.documentStore.has(i[this.ref])?t.update(i):t.add(i)},removeFromIndex:function(e){var t=this.index,i=e.toJSON();t.documentStore.has(i[this.ref])&&t.remove(i)},updateIndex:function(e){var i=e.changedAttributes();i&&!t.isEmpty(t.intersection(t.keys(this.fields),t.keys(i)))&&this.index.update(e.toJSON())},search:function(){for(var e=this.index.search(this.$("input[type=text]").val()),t=[],i=0;e.length>i;i++){var n=e[i];t.push(this.shadowCollection.get(n.ref))}this.collection.reset(t,{reindex:!1})}})})(jQuery,_,Backbone,Backgrid,lunr); \ No newline at end of file +(function(e,t,i,n){"use strict";var s=i.Extension.ServerSideFilter=i.View.extend({tagName:"form",className:"backgrid-filter form-search",template:e.template('
placeholder="<%- placeholder %>" <% } %> name="<%- name %>" />×
'),events:{"click .close":"clear",submit:"search"},name:"q",placeholder:null,initialize:function(e){i.requireOptions(e,["collection"]),i.View.prototype.initialize.apply(this,arguments),this.name=e.name||this.name,this.placeholder=e.placeholder||this.placeholder},searchBox:function(){return this.el.querySelector("input[type=text]")},search:function(e){e&&e.preventDefault();var t=this.searchBox(),i={};i[t.name]=t.value,this.collection.fetch({data:i})},clear:function(e){e&&e.preventDefault(),this.searchBox().value=null,this.collection.fetch()},render:function(){return this.empty().el.innerHTML=this.template({name:this.name,placeholder:this.placeholder,value:this.value}),this.delegateEvents(),this}}),a=i.Extension.ClientSideFilter=s.extend({events:{"click .close":function(e){e.preventDefault(),this.clear()},"change input[type=text]":"search","keyup input[type=text]":"search",submit:function(e){e.preventDefault(),this.search()}},fields:null,wait:149,initialize:function(t){s.prototype.initialize.apply(this,arguments),this.fields=t.fields||this.fields,this.wait=t.wait||this.wait,this._debounceMethods(["search","clear"]);var i=this.collection,n=this.shadowCollection=i.clone();n.url=i.url,n.sync=i.sync,n.parse=i.parse,this.listenTo(i,"add",function(e,t,i){n.add(e,i)}),this.listenTo(i,"remove",function(e,t,i){n.remove(e,i)}),this.listenTo(i,"sort reset",function(t,i){i=e.extend({reindex:!0},i||{}),i.reindex&&n.reset(t.models)})},_debounceMethods:function(t){e.isString(t)&&(t=[t]),this.undelegateEvents();for(var i=0,n=t.length;n>i;i++){var s=t[i],a=this[s];this[s]=e.debounce(a,this.wait)}this.delegateEvents()},makeMatcher:function(e){var t=RegExp(e.trim().split(/\W/).join("|"),"i");return function(e){for(var i=this.fields||e.keys(),n=0,s=i.length;s>n;n++)if(t.test(e.get(i[n])+""))return!0;return!1}},search:function(){var t=e.bind(this.makeMatcher(this.searchBox().value),this);this.collection.reset(this.shadowCollection.filter(t),{reindex:!1})},clear:function(){this.searchBox().value=null,this.collection.reset(this.shadowCollection.models,{reindex:!1})}});i.Extension.LunrFilter=a.extend({ref:"id",fields:null,initialize:function(e){a.prototype.initialize.apply(this,arguments),this.ref=e.ref||this.ref;var t=this.collection;this.listenTo(t,"add",this.addToIndex),this.listenTo(t,"remove",this.removeFromIndex),this.listenTo(t,"reset",this.resetIndex),this.listenTo(t,"change",this.updateIndex),this.resetIndex(t)},resetIndex:function(t,i){if(i=e.extend({reindex:!0},i||{}),i.reindex){var s=this;this.index=n(function(){e.each(s.fields,function(e,t){this.field(t,e),this.ref(s.ref)},this)}),t.each(function(e){this.addToIndex(e)},this)}},addToIndex:function(e){var t=this.index,i=e.toJSON();t.documentStore.has(i[this.ref])?t.update(i):t.add(i)},removeFromIndex:function(e){var t=this.index,i=e.toJSON();t.documentStore.has(i[this.ref])&&t.remove(i)},updateIndex:function(t){var i=t.changedAttributes();i&&!e.isEmpty(e.intersection(e.keys(this.fields),e.keys(i)))&&this.index.update(t.toJSON())},search:function(){for(var e=this.index.search(this.searchBox().value),t=[],i=0;e.length>i;i++){var n=e[i];t.push(this.shadowCollection.get(n.ref))}this.collection.reset(t,{reindex:!1})}})})(_,Backbone,Backgrid,lunr); \ No newline at end of file diff --git a/lib/extensions/moment-cell/backgrid-moment-cell.js b/lib/extensions/moment-cell/backgrid-moment-cell.js index 0af94fa4..08bb0e13 100644 --- a/lib/extensions/moment-cell/backgrid-moment-cell.js +++ b/lib/extensions/moment-cell/backgrid-moment-cell.js @@ -5,7 +5,7 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function ($, _, Backbone, Backgrid, moment) { +(function (_, Backbone, Backgrid, moment) { /** MomentFormatter converts bi-directionally any datetime values in any format @@ -142,4 +142,4 @@ _.extend(MomentCell.prototype, MomentFormatter.prototype.defaults); -}(jQuery, _, Backbone, Backgrid, moment)); +}(_, Backbone, Backgrid, moment)); diff --git a/lib/extensions/moment-cell/backgrid-moment-cell.min.js b/lib/extensions/moment-cell/backgrid-moment-cell.min.js index b70df0e2..4fc33562 100644 --- a/lib/extensions/moment-cell/backgrid-moment-cell.min.js +++ b/lib/extensions/moment-cell/backgrid-moment-cell.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(t,e,a,i,o){var l=i.Extension.MomentFormatter=function(t){e.extend(this,this.defaults,t)};l.prototype=new i.CellFormatter,e.extend(l.prototype,{defaults:{modelInUTC:!0,modelLang:o.lang(),modelFormat:o.defaultFormat,displayInUTC:!0,displayLang:o.lang(),displayFormat:o.defaultFormat},fromRaw:function(t){if(null==t)return"";var e=this.modelInUTC?o.utc(t,this.modelFormat,this.modelLang):o(t,this.modelFormat,this.modelLang);return this.displayLang&&e.lang(this.displayLang),this.displayInUTC?e.utc():e.local(),e.format(this.displayFormat)},toRaw:function(t){var e=this.displayInUTC?o.utc(t,this.displayFormat,this.displayLang):o(t,this.displayFormat,this.displayLang);if(e&&e.isValid())return this.modelLang&&e.lang(this.modelLang),this.modelInUTC?e.utc():e.local(),e.format(this.modelFormat)}});var r=i.Extension.MomentCell=i.Cell.extend({editor:i.InputCellEditor,className:"moment-cell",formatter:l,initialize:function(t){i.Cell.prototype.initialize.apply(this,arguments);var a=l.prototype.defaults,o=e.keys(a),r=e.pick(this,o),n=e.pick(t,o);this.formatter=new this.formatter(e.extend({},a,r,n)),this.editor=this.editor.extend({attributes:e.extend({},this.editor.prototype.attributes||this.editor.attributes||{},{placeholder:this.formatter.displayFormat})})}});e.extend(r.prototype,l.prototype.defaults)})(jQuery,_,Backbone,Backgrid,moment); \ No newline at end of file +(function(t,e,a,i){var o=a.Extension.MomentFormatter=function(e){t.extend(this,this.defaults,e)};o.prototype=new a.CellFormatter,t.extend(o.prototype,{defaults:{modelInUTC:!0,modelLang:i.lang(),modelFormat:i.defaultFormat,displayInUTC:!0,displayLang:i.lang(),displayFormat:i.defaultFormat},fromRaw:function(t){if(null==t)return"";var e=this.modelInUTC?i.utc(t,this.modelFormat,this.modelLang):i(t,this.modelFormat,this.modelLang);return this.displayLang&&e.lang(this.displayLang),this.displayInUTC?e.utc():e.local(),e.format(this.displayFormat)},toRaw:function(t){var e=this.displayInUTC?i.utc(t,this.displayFormat,this.displayLang):i(t,this.displayFormat,this.displayLang);if(e&&e.isValid())return this.modelLang&&e.lang(this.modelLang),this.modelInUTC?e.utc():e.local(),e.format(this.modelFormat)}});var l=a.Extension.MomentCell=a.Cell.extend({editor:a.InputCellEditor,className:"moment-cell",formatter:o,initialize:function(e){a.Cell.prototype.initialize.apply(this,arguments);var i=o.prototype.defaults,l=t.keys(i),n=t.pick(this,l),r=t.pick(e,l);this.formatter=new this.formatter(t.extend({},i,n,r)),this.editor=this.editor.extend({attributes:t.extend({},this.editor.prototype.attributes||this.editor.attributes||{},{placeholder:this.formatter.displayFormat})})}});t.extend(l.prototype,o.prototype.defaults)})(_,Backbone,Backgrid,moment); \ No newline at end of file diff --git a/lib/extensions/paginator/backgrid-paginator.js b/lib/extensions/paginator/backgrid-paginator.js index 4c89b1ad..3a9f2e63 100644 --- a/lib/extensions/paginator/backgrid-paginator.js +++ b/lib/extensions/paginator/backgrid-paginator.js @@ -6,7 +6,7 @@ Licensed under the MIT @license. */ -(function ($, _, Backbone, Backgrid) { +(function (_, Backbone, Backgrid) { "use strict"; @@ -21,7 +21,7 @@ @class Backgrid.Extension.Paginator */ - Backgrid.Extension.Paginator = Backbone.View.extend({ + Backgrid.Extension.Paginator = Backgrid.View.extend({ /** @property */ className: "backgrid-paginator", @@ -91,8 +91,8 @@ */ changePage: function (e) { e.preventDefault(); - - var label = $(e.target).text(); + var target = e.target; + var label = target.textContent || target.innerText; var ffLabels = this.fastForwardHandleLabels; var collection = this.collection; @@ -115,7 +115,7 @@ } var state = collection.state; - var pageIndex = $(e.target).text() * 1; + var pageIndex = label * 1; collection.getPage(state.firstPage === 0 ? pageIndex - 1 : pageIndex); }, @@ -189,11 +189,11 @@ cell that spans all the columns. */ render: function () { - this.$el.empty(); + this.empty(); - this.$el.append(this.template({ + this.el.innerHTML = this.template({ handles: this.makeHandles() - })); + }); this.delegateEvents(); @@ -202,4 +202,4 @@ }); -}(jQuery, _, Backbone, Backgrid)); +}(_, Backbone, Backgrid)); diff --git a/lib/extensions/paginator/backgrid-paginator.min.js b/lib/extensions/paginator/backgrid-paginator.min.js index f222b62e..733805e1 100644 --- a/lib/extensions/paginator/backgrid-paginator.min.js +++ b/lib/extensions/paginator/backgrid-paginator.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,s,i){"use strict";i.Extension.Paginator=s.View.extend({className:"backgrid-paginator",windowSize:10,fastForwardHandleLabels:{first:"《",prev:"〈",next:"〉",last:"》"},template:t.template(''),events:{"click a":"changePage"},initialize:function(e){i.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof s.Collection||(this.columns=new i.Columns(this.columns));var t=this.columns;this.listenTo(t,"add",this.render),this.listenTo(t,"remove",this.render),this.listenTo(t,"change:renderable",this.render);var a=this.collection,l=a.fullCollection;l?(this.listenTo(l,"add",this.render),this.listenTo(l,"remove",this.render),this.listenTo(l,"reset",this.render)):(this.listenTo(a,"add",this.render),this.listenTo(a,"remove",this.render),this.listenTo(a,"reset",this.render))},changePage:function(t){t.preventDefault();var s=e(t.target).text(),i=this.fastForwardHandleLabels,a=this.collection;if(i)switch(s){case i.first:return a.getFirstPage(),void 0;case i.prev:return a.hasPrevious()&&a.getPreviousPage(),void 0;case i.next:return a.hasNext()&&a.getNextPage(),void 0;case i.last:return a.getLastPage(),void 0}var l=a.state,n=1*e(t.target).text();a.getPage(0===l.firstPage?n-1:n)},makeHandles:function(){var e=[],t=this.collection,s=t.state,i=s.lastPage?s.lastPage:s.firstPage;i=0===s.firstPage?i:i-1;var a=0===s.firstPage?s.currentPage:s.currentPage-1,l=Math.floor(a/this.windowSize)*this.windowSize,n=l+this.windowSize;if(n=i>=n?n:i+1,"infinite"!==t.mode)for(var r=l;n>r;r++)e.push({label:r+1,title:"No. "+(r+1),className:a===r?"active":void 0});var o=this.fastForwardHandleLabels;return o&&(o.prev&&e.unshift({label:o.prev,className:t.hasPrevious()?void 0:"disabled"}),o.first&&e.unshift({label:o.first,className:t.hasPrevious()?void 0:"disabled"}),o.next&&e.push({label:o.next,className:t.hasNext()?void 0:"disabled"}),o.last&&e.push({label:o.last,className:t.hasNext()?void 0:"disabled"})),e},render:function(){return this.$el.empty(),this.$el.append(this.template({handles:this.makeHandles()})),this.delegateEvents(),this}})})(jQuery,_,Backbone,Backgrid); \ No newline at end of file +(function(e,t,s){"use strict";s.Extension.Paginator=s.View.extend({className:"backgrid-paginator",windowSize:10,fastForwardHandleLabels:{first:"《",prev:"〈",next:"〉",last:"》"},template:e.template(''),events:{"click a":"changePage"},initialize:function(e){s.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof t.Collection||(this.columns=new s.Columns(this.columns));var i=this.columns;this.listenTo(i,"add",this.render),this.listenTo(i,"remove",this.render),this.listenTo(i,"change:renderable",this.render);var a=this.collection,n=a.fullCollection;n?(this.listenTo(n,"add",this.render),this.listenTo(n,"remove",this.render),this.listenTo(n,"reset",this.render)):(this.listenTo(a,"add",this.render),this.listenTo(a,"remove",this.render),this.listenTo(a,"reset",this.render))},changePage:function(e){e.preventDefault();var t=e.target,s=t.textContent||t.innerText,i=this.fastForwardHandleLabels,a=this.collection;if(i)switch(s){case i.first:return a.getFirstPage(),void 0;case i.prev:return a.hasPrevious()&&a.getPreviousPage(),void 0;case i.next:return a.hasNext()&&a.getNextPage(),void 0;case i.last:return a.getLastPage(),void 0}var n=a.state,l=1*s;a.getPage(0===n.firstPage?l-1:l)},makeHandles:function(){var e=[],t=this.collection,s=t.state,i=s.lastPage?s.lastPage:s.firstPage;i=0===s.firstPage?i:i-1;var a=0===s.firstPage?s.currentPage:s.currentPage-1,n=Math.floor(a/this.windowSize)*this.windowSize,l=n+this.windowSize;if(l=i>=l?l:i+1,"infinite"!==t.mode)for(var r=n;l>r;r++)e.push({label:r+1,title:"No. "+(r+1),className:a===r?"active":void 0});var o=this.fastForwardHandleLabels;return o&&(o.prev&&e.unshift({label:o.prev,className:t.hasPrevious()?void 0:"disabled"}),o.first&&e.unshift({label:o.first,className:t.hasPrevious()?void 0:"disabled"}),o.next&&e.push({label:o.next,className:t.hasNext()?void 0:"disabled"}),o.last&&e.push({label:o.last,className:t.hasNext()?void 0:"disabled"})),e},render:function(){return this.empty(),this.el.innerHTML=this.template({handles:this.makeHandles()}),this.delegateEvents(),this}})})(_,Backbone,Backgrid); \ No newline at end of file diff --git a/lib/extensions/select-all/backgrid-select-all.js b/lib/extensions/select-all/backgrid-select-all.js index 2fd05eff..d90f3e23 100644 --- a/lib/extensions/select-all/backgrid-select-all.js +++ b/lib/extensions/select-all/backgrid-select-all.js @@ -5,15 +5,15 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function (window, $, _, Backbone, Backgrid) { +(function (_, Backbone, Backgrid) { /** Renders a checkbox for row selection. @class Backgrid.Extension.SelectRowCell - @extends Backbone.View + @extends Backgrid.View */ - var SelectRowCell = Backgrid.Extension.SelectRowCell = Backbone.View.extend({ + var SelectRowCell = Backgrid.Extension.SelectRowCell = Backgrid.View.extend({ /** @property */ className: "select-row-cell", @@ -23,9 +23,9 @@ /** @property */ events: { - "keydown :checkbox": "onKeydown", - "change :checkbox": "onChange", - "click :checkbox": "enterEditMode" + "keydown input[type=checkbox]": "onKeydown", + "change input[type=checkbox]": "onChange", + "click input[type=checkbox]": "enterEditMode" }, /** @@ -45,23 +45,27 @@ } this.listenTo(this.model, "backgrid:select", function (model, selected) { - this.$el.find(":checkbox").prop("checked", selected).change(); + this.checkbox().checked = selected; }); }, + checkbox: function () { + return this.el.querySelector("input[type=checkbox]"); + }, + /** Focuses the checkbox. */ enterEditMode: function () { - this.$el.find(":checkbox").focus(); + this.checkbox().focus(); }, /** Unfocuses the checkbox. */ exitEditMode: function () { - this.$el.find(":checkbox").blur(); + this.checkbox().blur(); }, /** @@ -72,7 +76,7 @@ if (command.passThru()) return true; // skip ahead to `change` if (command.cancel()) { e.stopPropagation(); - this.$el.find(":checkbox").blur(); + this.checkbox().blur(); } else if (command.save() || command.moveLeft() || command.moveRight() || command.moveUp() || command.moveDown()) { @@ -95,7 +99,7 @@ Renders a checkbox in a table cell. */ render: function () { - this.$el.empty().append(''); + this.empty().el.innerHTML = ''; this.delegateEvents(); return this; } @@ -148,7 +152,7 @@ if (selected) selectedModels[model.id || model.cid] = model; else { delete selectedModels[model.id || model.cid]; - this.$el.find(":checkbox").prop("checked", false); + this.checkbox().checked = false; } }); @@ -157,7 +161,7 @@ }); this.listenTo(collection, "backgrid:refresh", function () { - this.$el.find(":checkbox").prop("checked", false); + this.checkbox().checked = false; for (var i = 0; i < collection.length; i++) { var model = collection.at(i); if (selectedModels[model.id || model.cid]) { @@ -212,4 +216,4 @@ return result; }; -}(window, jQuery, _, Backbone, Backgrid)); +}(_, Backbone, Backgrid)); diff --git a/lib/extensions/select-all/backgrid-select-all.min.js b/lib/extensions/select-all/backgrid-select-all.min.js index a01ec69c..0ad0d699 100644 --- a/lib/extensions/select-all/backgrid-select-all.min.js +++ b/lib/extensions/select-all/backgrid-select-all.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,i,n,o){var c=o.Extension.SelectRowCell=n.View.extend({className:"select-row-cell",tagName:"td",events:{"keydown :checkbox":"onKeydown","change :checkbox":"onChange","click :checkbox":"enterEditMode"},initialize:function(e){o.requireOptions(e,["model","column"]),this.column=e.column,this.column instanceof o.Column||(this.column=new o.Column(this.column)),this.listenTo(this.model,"backgrid:select",function(e,t){this.$el.find(":checkbox").prop("checked",t).change()})},enterEditMode:function(){this.$el.find(":checkbox").focus()},exitEditMode:function(){this.$el.find(":checkbox").blur()},onKeydown:function(e){var t=new o.Command(e);return t.passThru()?!0:(t.cancel()?(e.stopPropagation(),this.$el.find(":checkbox").blur()):(t.save()||t.moveLeft()||t.moveRight()||t.moveUp()||t.moveDown())&&(e.preventDefault(),e.stopPropagation(),this.model.trigger("backgrid:edited",this.model,this.column,t)),void 0)},onChange:function(e){this.model.trigger("backgrid:selected",this.model,t(e.target).prop("checked"))},render:function(){return this.$el.empty().append(''),this.delegateEvents(),this}}),l=o.Extension.SelectAllHeaderCell=c.extend({className:"select-all-header-cell",tagName:"th",initialize:function(e){o.requireOptions(e,["column","collection"]),this.column=e.column,this.column instanceof o.Column||(this.column=new o.Column(this.column));var t=this.collection,i=this.selectedModels={};this.listenTo(t,"backgrid:selected",function(e,t){t?i[e.id||e.cid]=e:(delete i[e.id||e.cid],this.$el.find(":checkbox").prop("checked",!1))}),this.listenTo(t,"remove",function(e){delete i[e.cid]}),this.listenTo(t,"backgrid:refresh",function(){this.$el.find(":checkbox").prop("checked",!1);for(var e=0;t.length>e;e++){var n=t.at(e);i[n.id||n.cid]&&n.trigger("backgrid:select",n,!0)}})},onChange:function(e){var i=t(e.target).prop("checked"),n=this.collection;n.each(function(e){e.trigger("backgrid:select",e,i)})}});o.Grid.prototype.getSelectedModels=function(){for(var e,t=this.header.row.cells,i=0,n=t.length;n>i;i++){var o=t[i];if(o instanceof l){e=o;break}}var c=[];if(e)for(var s in e.selectedModels)c.push(this.collection.get(s));return c}})(window,jQuery,_,Backbone,Backgrid); \ No newline at end of file +(function(e,t,i){var n=i.Extension.SelectRowCell=i.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(e){i.requireOptions(e,["model","column"]),this.column=e.column,this.column instanceof i.Column||(this.column=new i.Column(this.column)),this.listenTo(this.model,"backgrid:select",function(e,t){this.checkbox().checked=t})},checkbox:function(){return this.el.querySelector("input[type=checkbox]")},enterEditMode:function(){this.checkbox().focus()},exitEditMode:function(){this.checkbox().blur()},onKeydown:function(e){var t=new i.Command(e);return t.passThru()?!0:(t.cancel()?(e.stopPropagation(),this.checkbox().blur()):(t.save()||t.moveLeft()||t.moveRight()||t.moveUp()||t.moveDown())&&(e.preventDefault(),e.stopPropagation(),this.model.trigger("backgrid:edited",this.model,this.column,t)),void 0)},onChange:function(e){this.model.trigger("backgrid:selected",this.model,$(e.target).prop("checked"))},render:function(){return this.empty().el.innerHTML='',this.delegateEvents(),this}}),c=i.Extension.SelectAllHeaderCell=n.extend({className:"select-all-header-cell",tagName:"th",initialize:function(e){i.requireOptions(e,["column","collection"]),this.column=e.column,this.column instanceof i.Column||(this.column=new i.Column(this.column));var t=this.collection,n=this.selectedModels={};this.listenTo(t,"backgrid:selected",function(e,t){t?n[e.id||e.cid]=e:(delete n[e.id||e.cid],this.checkbox().checked=!1)}),this.listenTo(t,"remove",function(e){delete n[e.cid]}),this.listenTo(t,"backgrid:refresh",function(){this.checkbox().checked=!1;for(var e=0;t.length>e;e++){var i=t.at(e);n[i.id||i.cid]&&i.trigger("backgrid:select",i,!0)}})},onChange:function(e){var t=$(e.target).prop("checked"),i=this.collection;i.each(function(e){e.trigger("backgrid:select",e,t)})}});i.Grid.prototype.getSelectedModels=function(){for(var e,t=this.header.row.cells,i=0,n=t.length;n>i;i++){var o=t[i];if(o instanceof c){e=o;break}}var l=[];if(e)for(var s in e.selectedModels)l.push(this.collection.get(s));return l}})(_,Backbone,Backgrid); \ No newline at end of file diff --git a/lib/extensions/select2-cell/backgrid-select2-cell.js b/lib/extensions/select2-cell/backgrid-select2-cell.js index d763ee88..8c8d4e5a 100644 --- a/lib/extensions/select2-cell/backgrid-select2-cell.js +++ b/lib/extensions/select2-cell/backgrid-select2-cell.js @@ -6,7 +6,7 @@ Licensed under the MIT @license. */ -(function (window, $, _, Backbone, Backgrid) { +(function (_, Backbone, Backgrid) { /** Select2CellEditor is a cell editor that renders a `select2` select box @@ -21,6 +21,8 @@ */ var Select2CellEditor = Backgrid.Extension.Select2CellEditor = Backgrid.SelectCellEditor.extend({ + use$: true, + /** @property */ events: { "close": "save", @@ -118,4 +120,4 @@ }); -}(window, jQuery, _, Backbone, Backgrid)); +}(_, Backbone, Backgrid)); diff --git a/lib/extensions/select2-cell/backgrid-select2-cell.min.js b/lib/extensions/select2-cell/backgrid-select2-cell.min.js index 46c449e1..69303d9f 100644 --- a/lib/extensions/select2-cell/backgrid-select2-cell.min.js +++ b/lib/extensions/select2-cell/backgrid-select2-cell.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,i,s,n){var l=n.Extension.Select2CellEditor=n.SelectCellEditor.extend({events:{close:"save",change:"save"},select2Options:null,initialize:function(){n.SelectCellEditor.prototype.initialize.apply(this,arguments),this.close=i.bind(this.close,this)},setSelect2Options:function(e){this.select2Options=i.extend({containerCssClass:"select2-container"},e||{})},render:function(){return n.SelectCellEditor.prototype.render.apply(this,arguments),this.$el.select2(this.select2Options),this.delegateEvents(),this},postRender:function(){var e=this;this.$el.parent().find("."+this.select2Options.containerCssClass).on("blur",function(t){t.relatedTarget||e.close(t)}).on("keydown",this.close).attr("tabindex",-1).focus()},remove:function(){return this.$el.select2("destroy"),n.SelectCellEditor.prototype.remove.apply(this,arguments)}});n.Extension.Select2Cell=n.SelectCell.extend({className:"select2-cell",editor:l,select2Options:null,initialize:function(e){n.SelectCell.prototype.initialize.apply(this,arguments),this.select2Options=e.select2Options||this.select2Options,this.listenTo(this.model,"backgrid:edit",function(e,t,i,s){t.get("name")==this.column.get("name")&&s.setSelect2Options(this.select2Options)})}})})(window,jQuery,_,Backbone,Backgrid); \ No newline at end of file +(function(e,t,s){var i=s.Extension.Select2CellEditor=s.SelectCellEditor.extend({use$:!0,events:{close:"save",change:"save"},select2Options:null,initialize:function(){s.SelectCellEditor.prototype.initialize.apply(this,arguments),this.close=e.bind(this.close,this)},setSelect2Options:function(t){this.select2Options=e.extend({containerCssClass:"select2-container"},t||{})},render:function(){return s.SelectCellEditor.prototype.render.apply(this,arguments),this.$el.select2(this.select2Options),this.delegateEvents(),this},postRender:function(){var e=this;this.$el.parent().find("."+this.select2Options.containerCssClass).on("blur",function(t){t.relatedTarget||e.close(t)}).on("keydown",this.close).attr("tabindex",-1).focus()},remove:function(){return this.$el.select2("destroy"),s.SelectCellEditor.prototype.remove.apply(this,arguments)}});s.Extension.Select2Cell=s.SelectCell.extend({className:"select2-cell",editor:i,select2Options:null,initialize:function(e){s.SelectCell.prototype.initialize.apply(this,arguments),this.select2Options=e.select2Options||this.select2Options,this.listenTo(this.model,"backgrid:edit",function(e,t,s,i){t.get("name")==this.column.get("name")&&i.setSelect2Options(this.select2Options)})}})})(_,Backbone,Backgrid); \ No newline at end of file diff --git a/lib/extensions/text-cell/backgrid-text-cell.js b/lib/extensions/text-cell/backgrid-text-cell.js index cdc4d575..4ad93fae 100644 --- a/lib/extensions/text-cell/backgrid-text-cell.js +++ b/lib/extensions/text-cell/backgrid-text-cell.js @@ -16,6 +16,8 @@ */ var TextareaEditor = Backgrid.Extension.TextareaEditor = Backgrid.CellEditor.extend({ + use$: true, + /** @property */ tagName: "div", diff --git a/lib/extensions/text-cell/backgrid-text-cell.min.js b/lib/extensions/text-cell/backgrid-text-cell.min.js index 8105bf3b..05acfeb7 100644 --- a/lib/extensions/text-cell/backgrid-text-cell.min.js +++ b/lib/extensions/text-cell/backgrid-text-cell.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,o,a,s){var i=s.Extension.TextareaEditor=s.CellEditor.extend({tagName:"div",className:"modal hide fade",template:o.template('
'),cols:80,rows:10,events:{submit:"save",hide:"cancel",hidden:"close",shown:"focus"},modalOptions:{backdrop:!1},render:function(){return this.$el.html(t(this.template({column:this.column,cols:this.cols,rows:this.rows,content:this.formatter.fromRaw(this.model.get(this.column.get("name")))}))),this.delegateEvents(),this.$el.modal(this.modalOptions),this},save:function(e){e&&e.preventDefault();var t=this.model,a=this.column,s=this.$el.find("textarea").val(),i=this.formatter.toRaw(s);o.isUndefined(i)?t.trigger("backgrid:error",t,a,s):(t.set(a.get("name"),i),this.$el.modal("hide"))},cancel:function(t){var o=this.formatter.toRaw(this.$el.find("textarea").val());return o!==(this.model.get(this.column.get("name"))||"").replace(/\r/g,"")&&e.confirm("Would you like to save your changes?")?(t.preventDefault(),t.stopPropagation(),this.save()):void 0},close:function(e){var t=this.model;t.trigger("backgrid:edited",t,this.column,new s.Command(e))},focus:function(){this.$el.find("textarea").focus()}});s.Extension.TextCell=s.StringCell.extend({className:"text-cell",editor:i})})(window,jQuery,_,Backbone,Backgrid); \ No newline at end of file +(function(e,t,o,s,a){var i=a.Extension.TextareaEditor=a.CellEditor.extend({use$:!0,tagName:"div",className:"modal hide fade",template:o.template('
'),cols:80,rows:10,events:{submit:"save",hide:"cancel",hidden:"close",shown:"focus"},modalOptions:{backdrop:!1},render:function(){return this.$el.html(t(this.template({column:this.column,cols:this.cols,rows:this.rows,content:this.formatter.fromRaw(this.model.get(this.column.get("name")))}))),this.delegateEvents(),this.$el.modal(this.modalOptions),this},save:function(e){e&&e.preventDefault();var t=this.model,s=this.column,a=this.$el.find("textarea").val(),i=this.formatter.toRaw(a);o.isUndefined(i)?t.trigger("backgrid:error",t,s,a):(t.set(s.get("name"),i),this.$el.modal("hide"))},cancel:function(t){var o=this.formatter.toRaw(this.$el.find("textarea").val());return o!==(this.model.get(this.column.get("name"))||"").replace(/\r/g,"")&&e.confirm("Would you like to save your changes?")?(t.preventDefault(),t.stopPropagation(),this.save()):void 0},close:function(e){var t=this.model;t.trigger("backgrid:edited",t,this.column,new a.Command(e))},focus:function(){this.$el.find("textarea").focus()}});a.Extension.TextCell=a.StringCell.extend({className:"text-cell",editor:i})})(window,jQuery,_,Backbone,Backgrid); \ No newline at end of file From 847abd329804feecd5a331a746a6791f673691c8 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Mon, 29 Apr 2013 05:36:10 +0800 Subject: [PATCH 03/31] Update API jsdoc --- ... data-2a1b304990c839ee109c21c60334cf02.js} | 44 +++++-- api/index.html | 9 +- api/output/Backgrid.Body.js | 14 ++- api/output/Backgrid.BooleanCell.js | 14 ++- api/output/Backgrid.BooleanCellEditor.js | 14 ++- api/output/Backgrid.Cell.js | 16 ++- api/output/Backgrid.CellEditor.js | 14 ++- api/output/Backgrid.DateCell.js | 14 ++- api/output/Backgrid.DatetimeCell.js | 14 ++- api/output/Backgrid.EmailCell.js | 14 ++- api/output/Backgrid.EmptyRow.js | 14 ++- .../Backgrid.Extension.ClientSideFilter.js | 2 +- api/output/Backgrid.Extension.LunrFilter.js | 2 +- api/output/Backgrid.Extension.MomentCell.js | 12 +- api/output/Backgrid.Extension.Select2Cell.js | 14 ++- .../Backgrid.Extension.Select2CellEditor.js | 12 +- .../Backgrid.Extension.SelectAllHeaderCell.js | 14 ++- .../Backgrid.Extension.SelectRowCell.js | 14 ++- api/output/Backgrid.Extension.TextCell.js | 14 ++- .../Backgrid.Extension.TextareaEditor.js | 12 +- api/output/Backgrid.Footer.js | 14 ++- api/output/Backgrid.Grid.js | 14 ++- api/output/Backgrid.Header.js | 16 ++- api/output/Backgrid.HeaderCell.js | 14 ++- api/output/Backgrid.HeaderRow.js | 14 ++- api/output/Backgrid.InputCellEditor.js | 12 +- api/output/Backgrid.IntegerCell.js | 14 ++- api/output/Backgrid.NumberCell.js | 14 ++- api/output/Backgrid.Row.js | 14 ++- api/output/Backgrid.SelectCell.js | 14 ++- api/output/Backgrid.SelectCellEditor.js | 14 ++- api/output/Backgrid.StringCell.js | 14 ++- api/output/Backgrid.TimeCell.js | 14 ++- api/output/Backgrid.UriCell.js | 14 ++- api/output/Backgrid.View.js | 107 ++++++++++++++++++ categories.json | 1 + 36 files changed, 477 insertions(+), 104 deletions(-) rename api/{data-03f6d0eff7392a61971ad69a7c3faeb8.js => data-2a1b304990c839ee109c21c60334cf02.js} (98%) create mode 100644 api/output/Backgrid.View.js diff --git a/api/data-03f6d0eff7392a61971ad69a7c3faeb8.js b/api/data-2a1b304990c839ee109c21c60334cf02.js similarity index 98% rename from api/data-03f6d0eff7392a61971ad69a7c3faeb8.js rename to api/data-2a1b304990c839ee109c21c60334cf02.js index f819b3c7..23115ed3 100644 --- a/api/data-03f6d0eff7392a61971ad69a7c3faeb8.js +++ b/api/data-2a1b304990c839ee109c21c60334cf02.js @@ -3,13 +3,13 @@ Docs = { "classes": [ { "name": "Backgrid.Body", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" }, { "name": "Backgrid.CellEditor", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" }, @@ -21,7 +21,7 @@ Docs = { }, { "name": "Backgrid.Cell", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" }, @@ -147,7 +147,7 @@ Docs = { }, { "name": "Backgrid.Extension.SelectRowCell", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" }, @@ -183,7 +183,7 @@ Docs = { }, { "name": "Backgrid.Footer", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" }, @@ -219,13 +219,13 @@ Docs = { }, { "name": "Backgrid.Grid", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" }, { "name": "Backgrid.HeaderCell", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" }, @@ -237,7 +237,7 @@ Docs = { }, { "name": "Backgrid.Header", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" }, @@ -247,15 +247,21 @@ Docs = { "private": null, "icon": "icon-class" }, + { + "name": "Backgrid.View", + "extends": null, + "private": null, + "icon": "icon-class" + }, { "name": "Backgrid.Row", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" }, { "name": "Backgrid.EmptyRow", - "extends": "Backbone.View", + "extends": "Backgrid.View", "private": null, "icon": "icon-class" } @@ -2468,6 +2474,24 @@ Docs = { }, "sort": 3 }, + { + "name": "View", + "fullName": "Backgrid.View", + "icon": "icon-class", + "url": "#!/api/Backgrid.View", + "meta": { + }, + "sort": 1 + }, + { + "name": "constructor", + "fullName": "Backgrid.View.constructor", + "icon": "icon-method", + "url": "#!/api/Backgrid.View-method-constructor", + "meta": { + }, + "sort": 3 + }, { "name": "Row", "fullName": "Backgrid.Row", diff --git a/api/index.html b/api/index.html index df38ef49..e02bee83 100644 --- a/api/index.html +++ b/api/index.html @@ -12,7 +12,7 @@ - + @@ -60,13 +60,13 @@

Formatters

  • Backgrid.NumberFormatter
  • Backgrid.DatetimeFormatter
  • - - +

    Headers

    Others

    - + diff --git a/api/output/Backgrid.Body.js b/api/output/Backgrid.Body.js index fb8c85cd..49aa1974 100644 --- a/api/output/Backgrid.Body.js +++ b/api/output/Backgrid.Body.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_Body({ "tagname": "class", "name": "Backgrid.Body", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -40,6 +40,14 @@ Ext.data.JsonP.Backgrid_Body({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "initialize", "tagname": "method", @@ -141,7 +149,7 @@ Ext.data.JsonP.Backgrid_Body({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ @@ -152,5 +160,5 @@ Ext.data.JsonP.Backgrid_Body({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Body

    Body is the table body which contains the rows inside a table. Body is\nresponsible for refreshing the rows after sorting, insertion and removal.

    \n
    Defined By

    Properties

    Backgrid.Body
    : String
    ...
    \n

    Defaults to: "tbody"

    Defined By

    Methods

    Backgrid.Body
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • collection : Backbone.Collection
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • row : Backgrid.Row (optional)

        The Row class to use.

        \n

        Defaults to: Backgrid.Row

      • emptyText : string (optional)

        The text to display in the empty row.

        \n

    Throws

    • TypeError

      If options.columns or options.collection is undefined.

      \n\n

      See Backgrid.Row.

      \n
    Backgrid.Body
    ( model, collection, options )
    This method can be called either directly or as a callback to a\nBackbone.Collecton#add event. ...

    This method can be called either directly or as a callback to a\nBackbone.Collecton#add event.

    \n\n

    When called directly, it accepts a model or an array of models and an\noption hash just like\nBackbone.Collection#add and\ndelegates to it. Once the model is added, a new row is inserted into the\nbody and automatically rendered.

    \n\n

    When called as a callback of an add event, splices a new row into the\nbody and renders it.

    \n

    Parameters

    • model : Backbone.Model

      The model to render as a row.

      \n
    • collection : Backbone.Collection

      When called directly, this\nparameter is actually the options to\nBackbone.Collection#add.

      \n
    • options : Object

      When called directly, this must be null.

      \n\n

      See:

      \n\n\n\n
    Backgrid.Body
    ( model, column, command )
    Moves focus to the next renderable and editable cell and return the\ncurrently editing cell to display mode. ...

    Moves focus to the next renderable and editable cell and return the\ncurrently editing cell to display mode.

    \n

    Parameters

    • model : Backbone.Model

      The originating model

      \n
    • column : Backgrid.Column

      The originating model column

      \n
    • command : Backgrid.Command

      The Command object constructed from a DOM\nEvent

      \n
    Backgrid.Body
    ( ) : Backgrid.Bodychainable
    Reinitialize all the rows inside the body and re-render them. ...

    Reinitialize all the rows inside the body and re-render them. Triggers a\nBackbone backgrid:refresh event from the collection along with the body\ninstance as its sole parameter when done.

    \n

    Returns

    Backgrid.Body
    ( ) : Backgrid.Bodychainable
    Clean up this body and it's rows. ...

    Clean up this body and it's rows.

    \n

    Returns

    Backgrid.Body
    ( model, collection, options )
    The method can be called either directly or as a callback to a\nBackbone.Collection#remove\nevent. ...

    The method can be called either directly or as a callback to a\nBackbone.Collection#remove\nevent.

    \n\n

    When called directly, it accepts a model or an array of models and an\noption hash just like\nBackbone.Collection#remove and\ndelegates to it. Once the model is removed, a corresponding row is removed\nfrom the body.

    \n\n

    When called as a callback of a remove event, splices into the rows and\nremoves the row responsible for rendering the model.

    \n

    Parameters

    • model : Backbone.Model

      The model to remove from the body.

      \n
    • collection : Backbone.Collection

      When called directly, this\nparameter is actually the options to\nBackbone.Collection#remove.

      \n
    • options : Object

      When called directly, this must be null.

      \n\n

      See:

      \n\n\n\n
    Backgrid.Body
    ( ) : Backgrid.Bodychainable
    Renders all the rows inside this body. ...

    Renders all the rows inside this body. If the collection is empty and\noptions.emptyText is defined and not null in the constructor, an empty\nrow is rendered, otherwise no row is rendered.

    \n

    Returns

    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Body

    Body is the table body which contains the rows inside a table. Body is\nresponsible for refreshing the rows after sorting, insertion and removal.

    \n
    Defined By

    Properties

    Backgrid.Body
    : String
    ...
    \n

    Defaults to: "tbody"

    Defined By

    Methods

    Backgrid.Body
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • collection : Backbone.Collection
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • row : Backgrid.Row (optional)

        The Row class to use.

        \n

        Defaults to: Backgrid.Row

      • emptyText : string (optional)

        The text to display in the empty row.

        \n

    Throws

    • TypeError

      If options.columns or options.collection is undefined.

      \n\n

      See Backgrid.Row.

      \n
    Backgrid.Body
    ( model, collection, options )
    This method can be called either directly or as a callback to a\nBackbone.Collecton#add event. ...

    This method can be called either directly or as a callback to a\nBackbone.Collecton#add event.

    \n\n

    When called directly, it accepts a model or an array of models and an\noption hash just like\nBackbone.Collection#add and\ndelegates to it. Once the model is added, a new row is inserted into the\nbody and automatically rendered.

    \n\n

    When called as a callback of an add event, splices a new row into the\nbody and renders it.

    \n

    Parameters

    • model : Backbone.Model

      The model to render as a row.

      \n
    • collection : Backbone.Collection

      When called directly, this\nparameter is actually the options to\nBackbone.Collection#add.

      \n
    • options : Object

      When called directly, this must be null.

      \n\n

      See:

      \n\n\n\n
    Backgrid.Body
    ( model, column, command )
    Moves focus to the next renderable and editable cell and return the\ncurrently editing cell to display mode. ...

    Moves focus to the next renderable and editable cell and return the\ncurrently editing cell to display mode.

    \n

    Parameters

    • model : Backbone.Model

      The originating model

      \n
    • column : Backgrid.Column

      The originating model column

      \n
    • command : Backgrid.Command

      The Command object constructed from a DOM\nEvent

      \n
    Backgrid.Body
    ( ) : Backgrid.Bodychainable
    Reinitialize all the rows inside the body and re-render them. ...

    Reinitialize all the rows inside the body and re-render them. Triggers a\nBackbone backgrid:refresh event from the collection along with the body\ninstance as its sole parameter when done.

    \n

    Returns

    Backgrid.Body
    ( ) : Backgrid.Bodychainable
    Clean up this body and it's rows. ...

    Clean up this body and it's rows.

    \n

    Returns

    Backgrid.Body
    ( model, collection, options )
    The method can be called either directly or as a callback to a\nBackbone.Collection#remove\nevent. ...

    The method can be called either directly or as a callback to a\nBackbone.Collection#remove\nevent.

    \n\n

    When called directly, it accepts a model or an array of models and an\noption hash just like\nBackbone.Collection#remove and\ndelegates to it. Once the model is removed, a corresponding row is removed\nfrom the body.

    \n\n

    When called as a callback of a remove event, splices into the rows and\nremoves the row responsible for rendering the model.

    \n

    Parameters

    • model : Backbone.Model

      The model to remove from the body.

      \n
    • collection : Backbone.Collection

      When called directly, this\nparameter is actually the options to\nBackbone.Collection#remove.

      \n
    • options : Object

      When called directly, this must be null.

      \n\n

      See:

      \n\n\n\n
    Backgrid.Body
    ( ) : Backgrid.Bodychainable
    Renders all the rows inside this body. ...

    Renders all the rows inside this body. If the collection is empty and\noptions.emptyText is defined and not null in the constructor, an empty\nrow is rendered, otherwise no row is rendered.

    \n

    Returns

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.BooleanCell.js b/api/output/Backgrid.BooleanCell.js index f8a6f8b7..c24ee0a4 100644 --- a/api/output/Backgrid.BooleanCell.js +++ b/api/output/Backgrid.BooleanCell.js @@ -72,6 +72,14 @@ Ext.data.JsonP.Backgrid_BooleanCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -133,7 +141,7 @@ Ext.data.JsonP.Backgrid_BooleanCell({ ] }, - "linenr": 644, + "linenr": 666, "files": [ { "filename": "cell.js", @@ -164,7 +172,7 @@ Ext.data.JsonP.Backgrid_BooleanCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell" ], "subclasses": [ @@ -176,5 +184,5 @@ Ext.data.JsonP.Backgrid_BooleanCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell
    Backgrid.BooleanCell

    BooleanCell renders a checkbox both during display mode and edit mode. The\ncheckbox is checked if the model value is true, unchecked otherwise.

    \n
    Defined By

    Properties

    Backgrid.BooleanCell
    : String
    ...
    \n

    Defaults to: "boolean-cell"

    Backgrid.BooleanCell
    editor : Object
    \n
    Backgrid.BooleanCell
    : Object
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Overrides: Backgrid.Cell.events

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Backgrid.BooleanCell
    ( ) : Backgrid.BooleanCellchainable
    Renders a checkbox and check it if the model value of this column is true,\nuncheck otherwise. ...

    Renders a checkbox and check it if the model value of this column is true,\nuncheck otherwise.

    \n

    Returns

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.BooleanCell

    BooleanCell renders a checkbox both during display mode and edit mode. The\ncheckbox is checked if the model value is true, unchecked otherwise.

    \n
    Defined By

    Properties

    Backgrid.BooleanCell
    : String
    ...
    \n

    Defaults to: "boolean-cell"

    Backgrid.BooleanCell
    editor : Object
    \n
    Backgrid.BooleanCell
    : Object
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Overrides: Backgrid.Cell.events

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Backgrid.BooleanCell
    ( ) : Backgrid.BooleanCellchainable
    Renders a checkbox and check it if the model value of this column is true,\nuncheck otherwise. ...

    Renders a checkbox and check it if the model value of this column is true,\nuncheck otherwise.

    \n

    Returns

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.BooleanCellEditor.js b/api/output/Backgrid.BooleanCellEditor.js index 821e5ee1..a9b09355 100644 --- a/api/output/Backgrid.BooleanCellEditor.js +++ b/api/output/Backgrid.BooleanCellEditor.js @@ -56,6 +56,14 @@ Ext.data.JsonP.Backgrid_BooleanCellEditor({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterOrExitEditMode", "tagname": "method", @@ -109,7 +117,7 @@ Ext.data.JsonP.Backgrid_BooleanCellEditor({ ] }, - "linenr": 558, + "linenr": 580, "files": [ { "filename": "cell.js", @@ -140,7 +148,7 @@ Ext.data.JsonP.Backgrid_BooleanCellEditor({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.CellEditor" ], "subclasses": [ @@ -152,5 +160,5 @@ Ext.data.JsonP.Backgrid_BooleanCellEditor({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.CellEditor
    Backgrid.BooleanCellEditor

    BooleanCellEditor renders a checkbox as its editor.

    \n
    Defined By

    Properties

    Backgrid.BooleanCellEditor
    attributes : Object
    \n
    \n
    Backgrid.BooleanCellEditor
    events : Object
    \n
    \n
    Backgrid.BooleanCellEditor
    : String
    ...
    \n

    Defaults to: "input"

    Defined By

    Methods

    Backgrid.BooleanCellEditor
    ( e )
    Event handler. ...

    Event handler. Hack to deal with the case where blur is fired before\nchange and click on a checkbox.

    \n

    Parameters

    • e : Object
      \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.BooleanCellEditor
    ( ) : Backgrid.BooleanCellEditorchainable
    Renders a checkbox and check it if the model value of this column is true,\nuncheck otherwise. ...

    Renders a checkbox and check it if the model value of this column is true,\nuncheck otherwise.

    \n

    Returns

    Backgrid.BooleanCellEditor
    ( e )
    Event handler. ...

    Event handler. Save the value into the model if the event is change or\none of the keyboard navigation key presses. Exit edit mode without saving\nif escape was pressed.

    \n

    Parameters

    • e : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.CellEditor
    Backgrid.BooleanCellEditor

    BooleanCellEditor renders a checkbox as its editor.

    \n
    Defined By

    Properties

    Backgrid.BooleanCellEditor
    attributes : Object
    \n
    \n
    Backgrid.BooleanCellEditor
    events : Object
    \n
    \n
    Backgrid.BooleanCellEditor
    : String
    ...
    \n

    Defaults to: "input"

    Defined By

    Methods

    Backgrid.BooleanCellEditor
    ( e )
    Event handler. ...

    Event handler. Hack to deal with the case where blur is fired before\nchange and click on a checkbox.

    \n

    Parameters

    • e : Object
      \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.BooleanCellEditor
    ( ) : Backgrid.BooleanCellEditorchainable
    Renders a checkbox and check it if the model value of this column is true,\nuncheck otherwise. ...

    Renders a checkbox and check it if the model value of this column is true,\nuncheck otherwise.

    \n

    Returns

    Backgrid.BooleanCellEditor
    ( e )
    Event handler. ...

    Event handler. Save the value into the model if the event is change or\none of the keyboard navigation key presses. Exit edit mode without saving\nif escape was pressed.

    \n

    Parameters

    • e : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Cell.js b/api/output/Backgrid.Cell.js index 40a40476..ab146171 100644 --- a/api/output/Backgrid.Cell.js +++ b/api/output/Backgrid.Cell.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_Cell({ "tagname": "class", "name": "Backgrid.Cell", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -65,6 +65,14 @@ Ext.data.JsonP.Backgrid_Cell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -126,7 +134,7 @@ Ext.data.JsonP.Backgrid_Cell({ ] }, - "linenr": 170, + "linenr": 177, "files": [ { "filename": "cell.js", @@ -158,7 +166,7 @@ Ext.data.JsonP.Backgrid_Cell({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ "Backgrid.BooleanCell", @@ -175,5 +183,5 @@ Ext.data.JsonP.Backgrid_Cell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell

    Subclasses

    The super-class for all Cell types. By default, this class renders a plain\ntable cell with the model value converted to a string using the\nformatter. The table cell is clickable, upon which the cell will go into\neditor mode, which is rendered by a Backgrid.InputCellEditor instance by\ndefault. Upon encountering any formatting errors, this class will add an\nerror CSS class to the table cell.

    \n
    Defined By

    Properties

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    Backgrid.Cell
    : Object
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Backgrid.Cell
    : Backgrid.CellFormatter|Object|string
    ...
    \n

    Defaults to: new CellFormatter()

    Backgrid.Cell
    : String
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    Backgrid.Cell
    ( )
    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Backgrid.Cell
    ( )
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.Cell
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Backgrid.Cell
    ( ) : Backgrid.Cellchainable
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Backgrid.Cell
    ( ) : Backgrid.Cellchainable
    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    Backgrid.Cell
    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell

    Subclasses

    The super-class for all Cell types. By default, this class renders a plain\ntable cell with the model value converted to a string using the\nformatter. The table cell is clickable, upon which the cell will go into\neditor mode, which is rendered by a Backgrid.InputCellEditor instance by\ndefault. Upon encountering any formatting errors, this class will add an\nerror CSS class to the table cell.

    \n
    Defined By

    Properties

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    Backgrid.Cell
    : Object
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Backgrid.Cell
    : Backgrid.CellFormatter|Object|string
    ...
    \n

    Defaults to: new CellFormatter()

    Backgrid.Cell
    : String
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    Backgrid.Cell
    ( )
    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Backgrid.Cell
    ( )
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.Cell
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Backgrid.Cell
    ( ) : Backgrid.Cellchainable
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Backgrid.Cell
    ( ) : Backgrid.Cellchainable
    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    Backgrid.Cell
    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.CellEditor.js b/api/output/Backgrid.CellEditor.js index 3f325566..6da1d0b8 100644 --- a/api/output/Backgrid.CellEditor.js +++ b/api/output/Backgrid.CellEditor.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_CellEditor({ "tagname": "class", "name": "Backgrid.CellEditor", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -34,6 +34,14 @@ Ext.data.JsonP.Backgrid_CellEditor({ ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "initialize", "tagname": "method", @@ -94,7 +102,7 @@ Ext.data.JsonP.Backgrid_CellEditor({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ "Backgrid.BooleanCellEditor", @@ -108,5 +116,5 @@ Ext.data.JsonP.Backgrid_CellEditor({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.CellEditor

    Subclasses

    Generic cell editor base class. Only defines an initializer for a number of\nrequired parameters.

    \n
    Defined By

    Methods

    Backgrid.CellEditor
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Backgrid.CellEditor
    ( model, column ) : Backgrid.CellEditorchainable
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.CellEditor

    Subclasses

    Generic cell editor base class. Only defines an initializer for a number of\nrequired parameters.

    \n
    Defined By

    Methods

    Backgrid.CellEditor
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Backgrid.CellEditor
    ( model, column ) : Backgrid.CellEditorchainable
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.DateCell.js b/api/output/Backgrid.DateCell.js index 6ed24572..4990d3b2 100644 --- a/api/output/Backgrid.DateCell.js +++ b/api/output/Backgrid.DateCell.js @@ -96,6 +96,14 @@ Ext.data.JsonP.Backgrid_DateCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -157,7 +165,7 @@ Ext.data.JsonP.Backgrid_DateCell({ ] }, - "linenr": 526, + "linenr": 548, "files": [ { "filename": "cell.js", @@ -188,7 +196,7 @@ Ext.data.JsonP.Backgrid_DateCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell", "Backgrid.DatetimeCell" ], @@ -201,5 +209,5 @@ Ext.data.JsonP.Backgrid_DateCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View

    DateCell is a Backgrid.DatetimeCell without the time part.

    \n
    Defined By

    Properties

    Backgrid.DateCell
    : String
    ...
    \n

    Defaults to: "date-cell"

    Overrides: Backgrid.DatetimeCell.className

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: Backgrid.DatetimeFormatter

    Overrides: Backgrid.Cell.formatter

    ...
    \n

    Defaults to: true

    ...
    \n

    Defaults to: false

    Backgrid.DateCell
    : Boolean
    ...
    \n

    Defaults to: false

    Overrides: Backgrid.DatetimeCell.includeTime

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializes this cell and the datetime formatter. ...

    Initializes this cell and the datetime formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    DateCell is a Backgrid.DatetimeCell without the time part.

    \n
    Defined By

    Properties

    Backgrid.DateCell
    : String
    ...
    \n

    Defaults to: "date-cell"

    Overrides: Backgrid.DatetimeCell.className

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: Backgrid.DatetimeFormatter

    Overrides: Backgrid.Cell.formatter

    ...
    \n

    Defaults to: true

    ...
    \n

    Defaults to: false

    Backgrid.DateCell
    : Boolean
    ...
    \n

    Defaults to: false

    Overrides: Backgrid.DatetimeCell.includeTime

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializes this cell and the datetime formatter. ...

    Initializes this cell and the datetime formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.DatetimeCell.js b/api/output/Backgrid.DatetimeCell.js index 3ed2b2bd..4f0f865a 100644 --- a/api/output/Backgrid.DatetimeCell.js +++ b/api/output/Backgrid.DatetimeCell.js @@ -96,6 +96,14 @@ Ext.data.JsonP.Backgrid_DatetimeCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -157,7 +165,7 @@ Ext.data.JsonP.Backgrid_DatetimeCell({ ] }, - "linenr": 460, + "linenr": 482, "files": [ { "filename": "cell.js", @@ -188,7 +196,7 @@ Ext.data.JsonP.Backgrid_DatetimeCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell" ], "subclasses": [ @@ -201,5 +209,5 @@ Ext.data.JsonP.Backgrid_DatetimeCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell
    Backgrid.DatetimeCell

    Subclasses

    DatetimeCell is a basic cell that accepts datetime string values in RFC-2822\nor W3C's subset of ISO-8601 and displays them in ISO-8601 format. For a much\nmore sophisticated date time cell with better datetime formatting, take a\nlook at the Backgrid.Extension.MomentCell extension. See:

    \n\n\n\n
    Defined By

    Properties

    Backgrid.DatetimeCell
    : String
    ...
    \n

    Defaults to: "datetime-cell"

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Backgrid.DatetimeCell
    : Backgrid.CellFormatter
    ...
    \n

    Defaults to: Backgrid.DatetimeFormatter

    Overrides: Backgrid.Cell.formatter

    Backgrid.DatetimeCell
    : boolean
    ...
    \n

    Defaults to: true

    Backgrid.DatetimeCell
    : boolean
    ...
    \n

    Defaults to: false

    Backgrid.DatetimeCell
    : boolean
    ...
    \n

    Defaults to: true

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.DatetimeCell
    ( options )
    Initializes this cell and the datetime formatter. ...

    Initializes this cell and the datetime formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.DatetimeCell

    Subclasses

    DatetimeCell is a basic cell that accepts datetime string values in RFC-2822\nor W3C's subset of ISO-8601 and displays them in ISO-8601 format. For a much\nmore sophisticated date time cell with better datetime formatting, take a\nlook at the Backgrid.Extension.MomentCell extension. See:

    \n\n\n\n
    Defined By

    Properties

    Backgrid.DatetimeCell
    : String
    ...
    \n

    Defaults to: "datetime-cell"

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Backgrid.DatetimeCell
    : Backgrid.CellFormatter
    ...
    \n

    Defaults to: Backgrid.DatetimeFormatter

    Overrides: Backgrid.Cell.formatter

    Backgrid.DatetimeCell
    : boolean
    ...
    \n

    Defaults to: true

    Backgrid.DatetimeCell
    : boolean
    ...
    \n

    Defaults to: false

    Backgrid.DatetimeCell
    : boolean
    ...
    \n

    Defaults to: true

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.DatetimeCell
    ( options )
    Initializes this cell and the datetime formatter. ...

    Initializes this cell and the datetime formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.EmailCell.js b/api/output/Backgrid.EmailCell.js index ff0d5297..368c9cbf 100644 --- a/api/output/Backgrid.EmailCell.js +++ b/api/output/Backgrid.EmailCell.js @@ -72,6 +72,14 @@ Ext.data.JsonP.Backgrid_EmailCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -133,7 +141,7 @@ Ext.data.JsonP.Backgrid_EmailCell({ ] }, - "linenr": 368, + "linenr": 388, "files": [ { "filename": "cell.js", @@ -164,7 +172,7 @@ Ext.data.JsonP.Backgrid_EmailCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell", "Backgrid.StringCell" ], @@ -177,5 +185,5 @@ Ext.data.JsonP.Backgrid_EmailCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View

    Like Backgrid.UriCell, EmailCell renders an HTML <a> anchor for the\nvalue. The href in the anchor is prefixed with mailto:. EmailCell will\ncomplain if the user enters a string that doesn't contain the @ sign.

    \n
    Defined By

    Properties

    Backgrid.EmailCell
    : String
    ...
    \n

    Defaults to: "email-cell"

    Overrides: Backgrid.StringCell.className

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Like Backgrid.UriCell, EmailCell renders an HTML <a> anchor for the\nvalue. The href in the anchor is prefixed with mailto:. EmailCell will\ncomplain if the user enters a string that doesn't contain the @ sign.

    \n
    Defined By

    Properties

    Backgrid.EmailCell
    : String
    ...
    \n

    Defaults to: "email-cell"

    Overrides: Backgrid.StringCell.className

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.EmptyRow.js b/api/output/Backgrid.EmptyRow.js index 65f4970b..18b5a507 100644 --- a/api/output/Backgrid.EmptyRow.js +++ b/api/output/Backgrid.EmptyRow.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_EmptyRow({ "tagname": "class", "name": "Backgrid.EmptyRow", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -48,6 +48,14 @@ Ext.data.JsonP.Backgrid_EmptyRow({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "initialize", "tagname": "method", @@ -107,7 +115,7 @@ Ext.data.JsonP.Backgrid_EmptyRow({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ @@ -118,5 +126,5 @@ Ext.data.JsonP.Backgrid_EmptyRow({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.EmptyRow

    EmptyRow is a simple container view that takes a list of column and render a\nrow with a single column.

    \n
    Defined By

    Properties

    Backgrid.EmptyRow
    emptyText : Object
    \n
    \n
    Backgrid.EmptyRow
    : String
    ...
    \n

    Defaults to: "tr"

    Defined By

    Methods

    Backgrid.EmptyRow
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Backgrid.EmptyRow
    ( ) : Backgrid.EmptyRowchainable
    Renders an empty row. ...

    Renders an empty row.

    \n

    Returns

    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.EmptyRow

    EmptyRow is a simple container view that takes a list of column and render a\nrow with a single column.

    \n
    Defined By

    Properties

    Backgrid.EmptyRow
    emptyText : Object
    \n
    \n
    Backgrid.EmptyRow
    : String
    ...
    \n

    Defaults to: "tr"

    Defined By

    Methods

    Backgrid.EmptyRow
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Backgrid.EmptyRow
    ( ) : Backgrid.EmptyRowchainable
    Renders an empty row. ...

    Renders an empty row.

    \n

    Returns

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Extension.ClientSideFilter.js b/api/output/Backgrid.Extension.ClientSideFilter.js index 49d8d9ad..c60d6ed5 100644 --- a/api/output/Backgrid.Extension.ClientSideFilter.js +++ b/api/output/Backgrid.Extension.ClientSideFilter.js @@ -148,7 +148,7 @@ Ext.data.JsonP.Backgrid_Extension_ClientSideFilter({ ] }, - "linenr": 94, + "linenr": 98, "files": [ { "filename": "backgrid-filter.js", diff --git a/api/output/Backgrid.Extension.LunrFilter.js b/api/output/Backgrid.Extension.LunrFilter.js index a4d2d3e4..006c0d87 100644 --- a/api/output/Backgrid.Extension.LunrFilter.js +++ b/api/output/Backgrid.Extension.LunrFilter.js @@ -196,7 +196,7 @@ Ext.data.JsonP.Backgrid_Extension_LunrFilter({ ] }, - "linenr": 227, + "linenr": 231, "files": [ { "filename": "backgrid-filter.js", diff --git a/api/output/Backgrid.Extension.MomentCell.js b/api/output/Backgrid.Extension.MomentCell.js index fc727777..11ae72b9 100644 --- a/api/output/Backgrid.Extension.MomentCell.js +++ b/api/output/Backgrid.Extension.MomentCell.js @@ -72,6 +72,14 @@ Ext.data.JsonP.Backgrid_Extension_MomentCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -164,7 +172,7 @@ Ext.data.JsonP.Backgrid_Extension_MomentCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell" ], "subclasses": [ @@ -176,5 +184,5 @@ Ext.data.JsonP.Backgrid_Extension_MomentCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell
    Backgrid.Extension.MomentCell

    Renders a datetime cell that uses a Backgrid.Extension.MomentFormatter to\nconvert and validate values.

    \n
    Defined By

    Properties

    Backgrid.Extension.MomentCell
    : String
    ...
    \n

    Defaults to: "moment-cell"

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Backgrid.Extension.MomentCell
    : Backgrid.CellFormatter
    ...
    \n

    Defaults to: Backgrid.Extension.MomentFormatter

    Overrides: Backgrid.Cell.formatter

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

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

    Initializer. Accept Backgrid.Extension.MomentFormatter.options and\nBackgrid.Cell.initialize required parameters.

    \n

    Parameters

    • options : Object
      \n

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.Extension.MomentCell

    Renders a datetime cell that uses a Backgrid.Extension.MomentFormatter to\nconvert and validate values.

    \n
    Defined By

    Properties

    Backgrid.Extension.MomentCell
    : String
    ...
    \n

    Defaults to: "moment-cell"

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Backgrid.Extension.MomentCell
    : Backgrid.CellFormatter
    ...
    \n

    Defaults to: Backgrid.Extension.MomentFormatter

    Overrides: Backgrid.Cell.formatter

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

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

    Initializer. Accept Backgrid.Extension.MomentFormatter.options and\nBackgrid.Cell.initialize required parameters.

    \n

    Parameters

    • options : Object
      \n

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Extension.Select2Cell.js b/api/output/Backgrid.Extension.Select2Cell.js index 6ae2c955..ee8609da 100644 --- a/api/output/Backgrid.Extension.Select2Cell.js +++ b/api/output/Backgrid.Extension.Select2Cell.js @@ -88,6 +88,14 @@ Ext.data.JsonP.Backgrid_Extension_Select2Cell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -149,7 +157,7 @@ Ext.data.JsonP.Backgrid_Extension_Select2Cell({ ] }, - "linenr": 81, + "linenr": 83, "files": [ { "filename": "backgrid-select2-cell.js", @@ -180,7 +188,7 @@ Ext.data.JsonP.Backgrid_Extension_Select2Cell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell", "Backgrid.SelectCell" ], @@ -193,5 +201,5 @@ Ext.data.JsonP.Backgrid_Extension_Select2Cell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell
    Backgrid.SelectCell
    Backgrid.Extension.Select2Cell

    Select2Cell is a cell class that renders a select2 select box during edit\nmode.

    \n
    Defined By

    Properties

    Backgrid.Extension.Select2Cell
    : String
    ...
    \n

    Defaults to: "select2-cell"

    Overrides: Backgrid.SelectCell.className

    Backgrid.Extension.Select2Cell
    editor : Object
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    optionValues : Array.<Array>|Array.<{name: string, values: Array.<Array>}>
    \n
    \n
    Backgrid.Extension.Select2Cell
    select2Options : Object
    \n
    \n
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

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

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • model : Backbone.Model
      • column : Backgrid.Column
      • select2Options : Object (optional)

    Throws

    • TypeError

      If optionsValues is undefined.

      \n

    Overrides: Backgrid.SelectCell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Renders the label using the raw value as key to look up from optionValues. ...

    Renders the label using the raw value as key to look up from optionValues.

    \n

    Returns

    Throws

    • TypeError

      If optionValues is malformed.

      \n

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.SelectCell
    Backgrid.Extension.Select2Cell

    Select2Cell is a cell class that renders a select2 select box during edit\nmode.

    \n
    Defined By

    Properties

    Backgrid.Extension.Select2Cell
    : String
    ...
    \n

    Defaults to: "select2-cell"

    Overrides: Backgrid.SelectCell.className

    Backgrid.Extension.Select2Cell
    editor : Object
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    optionValues : Array.<Array>|Array.<{name: string, values: Array.<Array>}>
    \n
    \n
    Backgrid.Extension.Select2Cell
    select2Options : Object
    \n
    \n
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

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

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • model : Backbone.Model
      • column : Backgrid.Column
      • select2Options : Object (optional)

    Throws

    • TypeError

      If optionsValues is undefined.

      \n

    Overrides: Backgrid.SelectCell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Renders the label using the raw value as key to look up from optionValues. ...

    Renders the label using the raw value as key to look up from optionValues.

    \n

    Returns

    Throws

    • TypeError

      If optionValues is malformed.

      \n

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Extension.Select2CellEditor.js b/api/output/Backgrid.Extension.Select2CellEditor.js index 42c556c7..c5f247ed 100644 --- a/api/output/Backgrid.Extension.Select2CellEditor.js +++ b/api/output/Backgrid.Extension.Select2CellEditor.js @@ -64,6 +64,14 @@ Ext.data.JsonP.Backgrid_Extension_Select2CellEditor({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "close", "tagname": "method", @@ -155,7 +163,7 @@ Ext.data.JsonP.Backgrid_Extension_Select2CellEditor({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.CellEditor", "Backgrid.SelectCellEditor" ], @@ -168,5 +176,5 @@ Ext.data.JsonP.Backgrid_Extension_Select2CellEditor({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.CellEditor
    Backgrid.SelectCellEditor
    Backgrid.Extension.Select2CellEditor

    Select2CellEditor is a cell editor that renders a select2 select box\ninstead of the default <select> HTML element.

    \n\n

    See:

    \n\n\n\n
    Defined By

    Properties

    Backgrid.Extension.Select2CellEditor
    : Object
    ...
    \n

    Defaults to: {"close": "save", "change": "save"}

    Overrides: Backgrid.SelectCellEditor.events

    Backgrid.Extension.Select2CellEditor
    select2Options : Object
    \n
    \n
    ...
    \n

    Defaults to: "select"

    template : function(Object, ?Object=): string
    \n
    \n
    Defined By

    Methods

    Triggers a backgrid:edited event from the model so the body can close\nthis editor. ...

    Triggers a backgrid:edited event from the model so the body can close\nthis editor.

    \n

    Parameters

    • e : Object
      \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Backgrid.Extension.Select2CellEditor
    ( )
    Attach event handlers to the select2 box and focus it. ...

    Attach event handlers to the select2 box and focus it.

    \n

    Overrides: Backgrid.CellEditor.postRender

    Backgrid.Extension.Select2CellEditor
    ( ) : Backgrid.Extension.Select2CellEditorchainable
    Renders a select2 select box instead of the default <select> HTML\nelement using the supplied options from selec...

    Renders a select2 select box instead of the default <select> HTML\nelement using the supplied options from select2Options.

    \n

    Returns

    Overrides: Backgrid.SelectCellEditor.render

    Saves the value of the selected option to the model attribute. ...

    Saves the value of the selected option to the model attribute. Triggers a\nbackgrid:edited Backbone event from the model.

    \n

    Parameters

    • e : Object
      \n
    Backgrid.Extension.Select2CellEditor
    ( options )
    Sets the options for select2. ...

    Sets the options for select2. Called by the parent Select2Cell during\nedit mode.

    \n

    Parameters

    • options : Object
      \n
    " + "html": "

    Hierarchy

    Select2CellEditor is a cell editor that renders a select2 select box\ninstead of the default <select> HTML element.

    \n\n

    See:

    \n\n\n\n
    Defined By

    Properties

    Backgrid.Extension.Select2CellEditor
    : Object
    ...
    \n

    Defaults to: {"close": "save", "change": "save"}

    Overrides: Backgrid.SelectCellEditor.events

    Backgrid.Extension.Select2CellEditor
    select2Options : Object
    \n
    \n
    ...
    \n

    Defaults to: "select"

    template : function(Object, ?Object=): string
    \n
    \n
    Defined By

    Methods

    Triggers a backgrid:edited event from the model so the body can close\nthis editor. ...

    Triggers a backgrid:edited event from the model so the body can close\nthis editor.

    \n

    Parameters

    • e : Object
      \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Backgrid.Extension.Select2CellEditor
    ( )
    Attach event handlers to the select2 box and focus it. ...

    Attach event handlers to the select2 box and focus it.

    \n

    Overrides: Backgrid.CellEditor.postRender

    Backgrid.Extension.Select2CellEditor
    ( ) : Backgrid.Extension.Select2CellEditorchainable
    Renders a select2 select box instead of the default <select> HTML\nelement using the supplied options from selec...

    Renders a select2 select box instead of the default <select> HTML\nelement using the supplied options from select2Options.

    \n

    Returns

    Overrides: Backgrid.SelectCellEditor.render

    Saves the value of the selected option to the model attribute. ...

    Saves the value of the selected option to the model attribute. Triggers a\nbackgrid:edited Backbone event from the model.

    \n

    Parameters

    • e : Object
      \n
    Backgrid.Extension.Select2CellEditor
    ( options )
    Sets the options for select2. ...

    Sets the options for select2. Called by the parent Select2Cell during\nedit mode.

    \n

    Parameters

    • options : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Extension.SelectAllHeaderCell.js b/api/output/Backgrid.Extension.SelectAllHeaderCell.js index 7343bede..65aa16c7 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": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -116,7 +124,7 @@ Ext.data.JsonP.Backgrid_Extension_SelectAllHeaderCell({ ] }, - "linenr": 105, + "linenr": 109, "files": [ { "filename": "backgrid-select-all.js", @@ -147,7 +155,7 @@ Ext.data.JsonP.Backgrid_Extension_SelectAllHeaderCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Extension.SelectRowCell" ], "subclasses": [ @@ -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 :checkbox": "onKeydown", "change :checkbox": "onChange", "click :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

    Overrides: Backgrid.Extension.SelectRowCell.initialize

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

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

    \n

    Parameters

    • e : Object
      \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

    Backgrid.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

    Overrides: Backgrid.Extension.SelectRowCell.initialize

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

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

    \n

    Parameters

    • e : Object
      \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 a635476a..10ba14d1 100644 --- a/api/output/Backgrid.Extension.SelectRowCell.js +++ b/api/output/Backgrid.Extension.SelectRowCell.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_Extension_SelectRowCell({ "tagname": "class", "name": "Backgrid.Extension.SelectRowCell", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -56,6 +56,14 @@ Ext.data.JsonP.Backgrid_Extension_SelectRowCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -147,7 +155,7 @@ Ext.data.JsonP.Backgrid_Extension_SelectRowCell({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ "Backgrid.Extension.SelectAllHeaderCell" @@ -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 :checkbox": "onKeydown", "change :checkbox": "onChange", "click :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

    Backgrid.Extension.SelectRowCell
    ( e )
    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

    Parameters

    • e : Object
      \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

    Backgrid.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

    Backgrid.Extension.SelectRowCell
    ( e )
    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

    Parameters

    • e : Object
      \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/api/output/Backgrid.Extension.TextCell.js b/api/output/Backgrid.Extension.TextCell.js index 1d283690..a4eddb68 100644 --- a/api/output/Backgrid.Extension.TextCell.js +++ b/api/output/Backgrid.Extension.TextCell.js @@ -72,6 +72,14 @@ Ext.data.JsonP.Backgrid_Extension_TextCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -133,7 +141,7 @@ Ext.data.JsonP.Backgrid_Extension_TextCell({ ] }, - "linenr": 135, + "linenr": 137, "files": [ { "filename": "backgrid-text-cell.js", @@ -164,7 +172,7 @@ Ext.data.JsonP.Backgrid_Extension_TextCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell", "Backgrid.StringCell" ], @@ -177,5 +185,5 @@ Ext.data.JsonP.Backgrid_Extension_TextCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell
    Backgrid.StringCell
    Backgrid.Extension.TextCell

    TextCell is a string cell type that renders a form with a text area in a\nmodal dialog instead of an input box editor. It is best suited for entering\na large body of text.

    \n
    Defined By

    Properties

    Backgrid.Extension.TextCell
    : String
    ...
    \n

    Defaults to: "text-cell"

    Overrides: Backgrid.StringCell.className

    Backgrid.Extension.TextCell
    editor : Object
    \n
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    TextCell is a string cell type that renders a form with a text area in a\nmodal dialog instead of an input box editor. It is best suited for entering\na large body of text.

    \n
    Defined By

    Properties

    Backgrid.Extension.TextCell
    : String
    ...
    \n

    Defaults to: "text-cell"

    Overrides: Backgrid.StringCell.className

    Backgrid.Extension.TextCell
    editor : Object
    \n
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Extension.TextareaEditor.js b/api/output/Backgrid.Extension.TextareaEditor.js index 78e8f85e..27219e12 100644 --- a/api/output/Backgrid.Extension.TextareaEditor.js +++ b/api/output/Backgrid.Extension.TextareaEditor.js @@ -88,6 +88,14 @@ Ext.data.JsonP.Backgrid_Extension_TextareaEditor({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "cancel", "tagname": "method", @@ -188,7 +196,7 @@ Ext.data.JsonP.Backgrid_Extension_TextareaEditor({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.CellEditor" ], "subclasses": [ @@ -200,5 +208,5 @@ Ext.data.JsonP.Backgrid_Extension_TextareaEditor({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.CellEditor
    Backgrid.Extension.TextareaEditor

    Renders a form with a text area and a save button in a modal dialog.

    \n
    Defined By

    Properties

    Backgrid.Extension.TextareaEditor
    : String
    ...
    \n

    Defaults to: "modal hide fade"

    Backgrid.Extension.TextareaEditor
    : Number
    ...
    \n

    Defaults to: 80

    Backgrid.Extension.TextareaEditor
    : Object
    ...
    \n

    Defaults to: {"submit": "save", "hide": "cancel", "hidden": "close", "shown": "focus"}

    Backgrid.Extension.TextareaEditor
    : Object
    The options passed to Bootstrap's modal\nplugin. ...

    The options passed to Bootstrap's modal\nplugin.

    \n

    Defaults to: {backdrop: false}

    Backgrid.Extension.TextareaEditor
    : Number
    ...
    \n

    Defaults to: 10

    Backgrid.Extension.TextareaEditor
    : String
    ...
    \n

    Defaults to: "div"

    Backgrid.Extension.TextareaEditor
    template : function(Object, ?Object=): string
    \n
    \n
    Defined By

    Methods

    Backgrid.Extension.TextareaEditor
    ( e )
    Event handler. ...

    Event handler. Revert the text in the model after asking for confirmation\nif dirty, otherwise just close the editor.

    \n

    Parameters

    • e : Event
      \n
    Backgrid.Extension.TextareaEditor
    ( e )
    Triggers a backgrid:edited event along with the cell editor as the\nparameter after the modal is hidden. ...

    Triggers a backgrid:edited event along with the cell editor as the\nparameter after the modal is hidden.

    \n

    Parameters

    • e : Event
      \n
    Backgrid.Extension.TextareaEditor
    ( )
    Focuses the textarea when the modal is shown. ...

    Focuses the textarea when the modal is shown.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.Extension.TextareaEditor
    ( ) : Backgrid.Extension.TextareaEditorchainable
    Renders a modal form dialog with a textarea, submit button and a close button. ...

    Renders a modal form dialog with a textarea, submit button and a close button.

    \n

    Returns

    Backgrid.Extension.TextareaEditor
    ( e )
    Event handler. ...

    Event handler. Saves the text in the text area to the model.

    \n\n

    Triggers a Backbone backgrid:error event along with the editor as the\nparameter if the value cannot be converted. Classes listening to the\nbackgrid:error event, usually the Cell classes, should respond\nappropriately, usually by rendering some kind of error feedback.

    \n

    Parameters

    • e : Event
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.CellEditor
    Backgrid.Extension.TextareaEditor

    Renders a form with a text area and a save button in a modal dialog.

    \n
    Defined By

    Properties

    Backgrid.Extension.TextareaEditor
    : String
    ...
    \n

    Defaults to: "modal hide fade"

    Backgrid.Extension.TextareaEditor
    : Number
    ...
    \n

    Defaults to: 80

    Backgrid.Extension.TextareaEditor
    : Object
    ...
    \n

    Defaults to: {"submit": "save", "hide": "cancel", "hidden": "close", "shown": "focus"}

    Backgrid.Extension.TextareaEditor
    : Object
    The options passed to Bootstrap's modal\nplugin. ...

    The options passed to Bootstrap's modal\nplugin.

    \n

    Defaults to: {backdrop: false}

    Backgrid.Extension.TextareaEditor
    : Number
    ...
    \n

    Defaults to: 10

    Backgrid.Extension.TextareaEditor
    : String
    ...
    \n

    Defaults to: "div"

    Backgrid.Extension.TextareaEditor
    template : function(Object, ?Object=): string
    \n
    \n
    Defined By

    Methods

    Backgrid.Extension.TextareaEditor
    ( e )
    Event handler. ...

    Event handler. Revert the text in the model after asking for confirmation\nif dirty, otherwise just close the editor.

    \n

    Parameters

    • e : Event
      \n
    Backgrid.Extension.TextareaEditor
    ( e )
    Triggers a backgrid:edited event along with the cell editor as the\nparameter after the modal is hidden. ...

    Triggers a backgrid:edited event along with the cell editor as the\nparameter after the modal is hidden.

    \n

    Parameters

    • e : Event
      \n
    Backgrid.Extension.TextareaEditor
    ( )
    Focuses the textarea when the modal is shown. ...

    Focuses the textarea when the modal is shown.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.Extension.TextareaEditor
    ( ) : Backgrid.Extension.TextareaEditorchainable
    Renders a modal form dialog with a textarea, submit button and a close button. ...

    Renders a modal form dialog with a textarea, submit button and a close button.

    \n

    Returns

    Backgrid.Extension.TextareaEditor
    ( e )
    Event handler. ...

    Event handler. Saves the text in the text area to the model.

    \n\n

    Triggers a Backbone backgrid:error event along with the editor as the\nparameter if the value cannot be converted. Classes listening to the\nbackgrid:error event, usually the Cell classes, should respond\nappropriately, usually by rendering some kind of error feedback.

    \n

    Parameters

    • e : Event
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Footer.js b/api/output/Backgrid.Footer.js index 640ef928..1c9d6820 100644 --- a/api/output/Backgrid.Footer.js +++ b/api/output/Backgrid.Footer.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_Footer({ "tagname": "class", "name": "Backgrid.Footer", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -41,6 +41,14 @@ Ext.data.JsonP.Backgrid_Footer({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "initialize", "tagname": "method", @@ -92,7 +100,7 @@ Ext.data.JsonP.Backgrid_Footer({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ @@ -103,5 +111,5 @@ Ext.data.JsonP.Backgrid_Footer({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Footer

    A Footer is a generic class that only defines a default tag tfoot and\nnumber of required parameters in the initializer.

    \n
    Defined By

    Properties

    Backgrid.Footer
    : String
    ...
    \n

    Defaults to: "tfoot"

    Defined By

    Methods

    Backgrid.Footer
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • parent : *

        The parent view class of this footer.

        \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • collection : Backbone.Collection

    Throws

    • TypeError

      If options.columns or options.collection is undefined.

      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Footer

    A Footer is a generic class that only defines a default tag tfoot and\nnumber of required parameters in the initializer.

    \n
    Defined By

    Properties

    Backgrid.Footer
    : String
    ...
    \n

    Defaults to: "tfoot"

    Defined By

    Methods

    Backgrid.Footer
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • parent : *

        The parent view class of this footer.

        \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • collection : Backbone.Collection

    Throws

    • TypeError

      If options.columns or options.collection is undefined.

      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Grid.js b/api/output/Backgrid.Grid.js index e18fb2d0..d9c0bfb5 100644 --- a/api/output/Backgrid.Grid.js +++ b/api/output/Backgrid.Grid.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_Grid({ "tagname": "class", "name": "Backgrid.Grid", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -72,6 +72,14 @@ Ext.data.JsonP.Backgrid_Grid({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "getSelectedModels", "tagname": "method", @@ -182,7 +190,7 @@ Ext.data.JsonP.Backgrid_Grid({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ @@ -193,5 +201,5 @@ Ext.data.JsonP.Backgrid_Grid({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Grid

    Grid represents a data grid that has a header, body and an optional footer.

    \n\n

    By default, a Grid treats each model in a collection as a row, and each\nattribute in a model as a column. To render a grid you must provide a list of\ncolumn metadata and a collection to the Grid constructor. Just like any\nBackbone.View class, the grid is rendered as a DOM node fragment when you\ncall render().

    \n\n
    var grid = Backgrid.Grid({\n  columns: [{ name: \"id\", label: \"ID\", type: \"string\" },\n   // ...\n  ],\n  collections: books\n});\n\n$(\"#table-container\").append(grid.render().el);\n
    \n\n

    Optionally, if you want to customize the rendering of the grid's header and\nfooter, you may choose to extend Backgrid.Header and Backgrid.Footer, and\nthen supply that class or an instance of that class to the Grid constructor.\nSee the documentation for Header and Footer for further details.

    \n\n
    var grid = Backgrid.Grid({\n  columns: [{ name: \"id\", label: \"ID\", type: \"string\" }],\n  collections: books,\n  header: Backgrid.Header.extend({\n       //...\n  }),\n  footer: Backgrid.Paginator\n});\n
    \n\n

    Finally, if you want to override how the rows are rendered in the table body,\nyou can supply a Body subclass as the body attribute that uses a different\nRow class. See:

    \n\n\n\n
    Defined By

    Properties

    Backgrid.Grid
    body : Object
    \n
    \n
    Backgrid.Grid
    : String
    ...
    \n

    Defaults to: "backgrid"

    Backgrid.Grid
    header : Object
    \n
    \n
    Backgrid.Grid
    : String
    ...
    \n

    Defaults to: "table"

    Defined By

    Methods

    Backgrid.Grid
    ( ) : Array.<Backbone.Model>
    Convenient method to retrieve a list of selected models. ...

    Convenient method to retrieve a list of selected models. This method only\nexists when the SelectAll extension has been included.

    \n

    Returns

    • Array.<Backbone.Model>
      \n
    Backgrid.Grid
    ( options )
    Initializes a Grid instance. ...

    Initializes a Grid instance.

    \n

    Parameters

    • options : Object
      \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • collection : Backbone.Collection

        The collection of tabular model data to display.

        \n
      • header : Backgrid.Header (optional)

        An optional Header class to override the default.

        \n

        Defaults to: Backgrid.Header

      • body : Backgrid.Body (optional)

        An optional Body class to override the default.

        \n

        Defaults to: Backgrid.Body

      • row : Backgrid.Row (optional)

        An optional Row class to override the default.

        \n

        Defaults to: Backgrid.Row

      • footer : Backgrid.Footer (optional)

        An optional Footer class.

        \n

        Defaults to: Backgrid.Footer

    Backgrid.Grid
    ( [options] ) : Backgrid.Gridchainable
    Delegates to Backgrid.Columns#add for adding a column. ...

    Delegates to Backgrid.Columns#add for adding a column. Subviews can listen\nto the add event from their internal columns if rerendering needs to\nhappen.

    \n

    Parameters

    • options : Object (optional)

      Options for Backgrid.Columns#add.

      \n
      • render : boolean (optional)

        Whether to render the column\nimmediately after insertion.

        \n

        Defaults to: true

    Returns

    Backgrid.Grid
    ( model, collection, options )
    Delegates to Backgrid.Body.insertRow. ...

    Delegates to Backgrid.Body.insertRow.

    \n

    Parameters

    • model : Object
      \n
    • collection : Object
      \n
    • options : Object
      \n
    Backgrid.Grid
    ( ) : Backgrid.Gridchainable
    Clean up this grid and its subviews. ...

    Clean up this grid and its subviews.

    \n

    Returns

    Backgrid.Grid
    ( [options] ) : Backgrid.Gridchainable
    Delegates to Backgrid.Columns#remove for removing a column. ...

    Delegates to Backgrid.Columns#remove for removing a column. Subviews can\nlisten to the remove event from the internal columns if rerendering\nneeds to happen.

    \n

    Parameters

    • options : Object (optional)

      Options for Backgrid.Columns#remove.

      \n

    Returns

    Backgrid.Grid
    ( model, collection, options )
    Delegates to Backgrid.Body.removeRow. ...

    Delegates to Backgrid.Body.removeRow.

    \n

    Parameters

    • model : Object
      \n
    • collection : Object
      \n
    • options : Object
      \n
    Backgrid.Grid
    ( ) : Backgrid.Gridchainable
    Renders the grid's header, then footer, then finally the body. ...

    Renders the grid's header, then footer, then finally the body. Triggers a\nBackbone backgrid:rendered event along with a reference to the grid when\nthe it has successfully been rendered.

    \n

    Returns

    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Grid

    Grid represents a data grid that has a header, body and an optional footer.

    \n\n

    By default, a Grid treats each model in a collection as a row, and each\nattribute in a model as a column. To render a grid you must provide a list of\ncolumn metadata and a collection to the Grid constructor. Just like any\nBackgrid.View class, the grid is rendered as a DOM node fragment when you\ncall render().

    \n\n
    var grid = Backgrid.Grid({\n  columns: [{ name: \"id\", label: \"ID\", type: \"string\" },\n   // ...\n  ],\n  collections: books\n});\n\n$(\"#table-container\").append(grid.render().el);\n
    \n\n

    Optionally, if you want to customize the rendering of the grid's header and\nfooter, you may choose to extend Backgrid.Header and Backgrid.Footer, and\nthen supply that class or an instance of that class to the Grid constructor.\nSee the documentation for Header and Footer for further details.

    \n\n
    var grid = Backgrid.Grid({\n  columns: [{ name: \"id\", label: \"ID\", type: \"string\" }],\n  collections: books,\n  header: Backgrid.Header.extend({\n       //...\n  }),\n  footer: Backgrid.Paginator\n});\n
    \n\n

    Finally, if you want to override how the rows are rendered in the table body,\nyou can supply a Body subclass as the body attribute that uses a different\nRow class. See:

    \n\n\n\n
    Defined By

    Properties

    Backgrid.Grid
    body : Object
    \n
    \n
    Backgrid.Grid
    : String
    ...
    \n

    Defaults to: "backgrid"

    Backgrid.Grid
    header : Object
    \n
    \n
    Backgrid.Grid
    : String
    ...
    \n

    Defaults to: "table"

    Defined By

    Methods

    Backgrid.Grid
    ( ) : Array.<Backbone.Model>
    Convenient method to retrieve a list of selected models. ...

    Convenient method to retrieve a list of selected models. This method only\nexists when the SelectAll extension has been included.

    \n

    Returns

    • Array.<Backbone.Model>
      \n
    Backgrid.Grid
    ( options )
    Initializes a Grid instance. ...

    Initializes a Grid instance.

    \n

    Parameters

    • options : Object
      \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • collection : Backbone.Collection

        The collection of tabular model data to display.

        \n
      • header : Backgrid.Header (optional)

        An optional Header class to override the default.

        \n

        Defaults to: Backgrid.Header

      • body : Backgrid.Body (optional)

        An optional Body class to override the default.

        \n

        Defaults to: Backgrid.Body

      • row : Backgrid.Row (optional)

        An optional Row class to override the default.

        \n

        Defaults to: Backgrid.Row

      • footer : Backgrid.Footer (optional)

        An optional Footer class.

        \n

        Defaults to: Backgrid.Footer

    Backgrid.Grid
    ( [options] ) : Backgrid.Gridchainable
    Delegates to Backgrid.Columns#add for adding a column. ...

    Delegates to Backgrid.Columns#add for adding a column. Subviews can listen\nto the add event from their internal columns if rerendering needs to\nhappen.

    \n

    Parameters

    • options : Object (optional)

      Options for Backgrid.Columns#add.

      \n
      • render : boolean (optional)

        Whether to render the column\nimmediately after insertion.

        \n

        Defaults to: true

    Returns

    Backgrid.Grid
    ( model, collection, options )
    Delegates to Backgrid.Body.insertRow. ...

    Delegates to Backgrid.Body.insertRow.

    \n

    Parameters

    • model : Object
      \n
    • collection : Object
      \n
    • options : Object
      \n
    Backgrid.Grid
    ( ) : Backgrid.Gridchainable
    Clean up this grid and its subviews. ...

    Clean up this grid and its subviews.

    \n

    Returns

    Backgrid.Grid
    ( [options] ) : Backgrid.Gridchainable
    Delegates to Backgrid.Columns#remove for removing a column. ...

    Delegates to Backgrid.Columns#remove for removing a column. Subviews can\nlisten to the remove event from the internal columns if rerendering\nneeds to happen.

    \n

    Parameters

    • options : Object (optional)

      Options for Backgrid.Columns#remove.

      \n

    Returns

    Backgrid.Grid
    ( model, collection, options )
    Delegates to Backgrid.Body.removeRow. ...

    Delegates to Backgrid.Body.removeRow.

    \n

    Parameters

    • model : Object
      \n
    • collection : Object
      \n
    • options : Object
      \n
    Backgrid.Grid
    ( ) : Backgrid.Gridchainable
    Renders the grid's header, then footer, then finally the body. ...

    Renders the grid's header, then footer, then finally the body. Triggers a\nBackbone backgrid:rendered event along with a reference to the grid when\nthe it has successfully been rendered.

    \n

    Returns

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Header.js b/api/output/Backgrid.Header.js index 5b1c49b0..e13e530e 100644 --- a/api/output/Backgrid.Header.js +++ b/api/output/Backgrid.Header.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_Header({ "tagname": "class", "name": "Backgrid.Header", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -40,6 +40,14 @@ Ext.data.JsonP.Backgrid_Header({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "initialize", "tagname": "method", @@ -77,7 +85,7 @@ Ext.data.JsonP.Backgrid_Header({ ] }, - "linenr": 241, + "linenr": 246, "files": [ { "filename": "header.js", @@ -108,7 +116,7 @@ Ext.data.JsonP.Backgrid_Header({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ @@ -119,5 +127,5 @@ Ext.data.JsonP.Backgrid_Header({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Header

    Header is a special structural view class that renders a table head with a\nsingle row of header cells.

    \n
    Defined By

    Properties

    Backgrid.Header
    : String
    ...
    \n

    Defaults to: "thead"

    Defined By

    Methods

    Backgrid.Header
    ( options )
    Initializer. ...

    Initializer. Initializes this table head view to contain a single header\nrow view.

    \n

    Parameters

    • options : Object
      \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • model : Backbone.Model

        The model instance to render.

        \n

    Throws

    • TypeError

      If options.columns or options.model is undefined.

      \n
    Backgrid.Header
    ( ) : Backgrid.Headerchainable
    Clean up this header and its row. ...

    Clean up this header and its row.

    \n

    Returns

    Backgrid.Header
    ( ) : Backgrid.Headerchainable
    Renders this table head with a single row of header cells. ...

    Renders this table head with a single row of header cells.

    \n

    Returns

    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Header

    Header is a special structural view class that renders a table head with a\nsingle row of header cells.

    \n
    Defined By

    Properties

    Backgrid.Header
    : String
    ...
    \n

    Defaults to: "thead"

    Defined By

    Methods

    Backgrid.Header
    ( options )
    Initializer. ...

    Initializer. Initializes this table head view to contain a single header\nrow view.

    \n

    Parameters

    • options : Object
      \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • model : Backbone.Model

        The model instance to render.

        \n

    Throws

    • TypeError

      If options.columns or options.model is undefined.

      \n
    Backgrid.Header
    ( ) : Backgrid.Headerchainable
    Clean up this header and its row. ...

    Clean up this header and its row.

    \n

    Returns

    Backgrid.Header
    ( ) : Backgrid.Headerchainable
    Renders this table head with a single row of header cells. ...

    Renders this table head with a single row of header cells.

    \n

    Returns

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.HeaderCell.js b/api/output/Backgrid.HeaderCell.js index 188b8fad..a7a48b51 100644 --- a/api/output/Backgrid.HeaderCell.js +++ b/api/output/Backgrid.HeaderCell.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_HeaderCell({ "tagname": "class", "name": "Backgrid.HeaderCell", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -56,6 +56,14 @@ Ext.data.JsonP.Backgrid_HeaderCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "_cidComparator", "tagname": "method", @@ -157,7 +165,7 @@ Ext.data.JsonP.Backgrid_HeaderCell({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ @@ -168,5 +176,5 @@ Ext.data.JsonP.Backgrid_HeaderCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.HeaderCell

    HeaderCell is a special cell class that renders a column header cell. If the\ncolumn is sortable, a sorter is also rendered and will trigger a table\nrefresh after sorting.

    \n
    Defined By

    Properties

    Backgrid.HeaderCell
    _direction : null|\"ascending\"|\"descending\"

    The current sorting\ndirection of this column.

    \n

    The current sorting\ndirection of this column.

    \n
    Backgrid.HeaderCell
    : Object
    ...
    \n

    Defaults to: {"click a": "onClick"}

    Backgrid.HeaderCell
    : String
    ...
    \n

    Defaults to: "th"

    Defined By

    Methods

    Backgrid.HeaderCell
    ( left, right )private
    Default comparator for Backbone.Collections. ...

    Default comparator for Backbone.Collections. Sorts cids in ascending\norder. The cids of the models are assumed to be in insertion order.

    \n

    Parameters

    • left : *
      \n
    • right : *
      \n
    Backgrid.HeaderCell
    ( sortByColName, direction, comparator, collection )private
    Event handler for the Backbone backgrid:sort event. ...

    Event handler for the Backbone backgrid:sort event. Resets this cell's\ndirection to default if sorting is being done on another column.

    \n

    Parameters

    • sortByColName : Object
      \n
    • direction : Object
      \n
    • comparator : Object
      \n
    • collection : Object
      \n
    Backgrid.HeaderCell
    ( dir ) : null|string
    Gets or sets the direction of this cell. ...

    Gets or sets the direction of this cell. If called directly without\nparameters, returns the current direction of this cell, otherwise sets\nit. If a null is given, sets this cell back to the default order.

    \n

    Parameters

    • dir : null|\"ascending\"|\"descending\"
      \n

    Returns

    • null|string

      The current direction or the changed direction.

      \n
    Backgrid.HeaderCell
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If options.column or options.collection is undefined.

      \n
    Backgrid.HeaderCell
    ( e )
    Event handler for the click event on the cell's anchor. ...

    Event handler for the click event on the cell's anchor. If the column is\nsortable, clicking on the anchor will cycle through 3 sorting orderings -\nascending, descending, and default.

    \n

    Parameters

    • e : Object
      \n
    Backgrid.HeaderCell
    ( ) : Backgrid.HeaderCellchainable
    Renders a header cell with a sorter and a label. ...

    Renders a header cell with a sorter and a label.

    \n

    Returns

    Backgrid.HeaderCell
    ( columnName, direction, [comparator] )
    If the underlying collection is a Backbone.PageableCollection in\nserver-mode or infinite-mode, a page of models is fe...

    If the underlying collection is a Backbone.PageableCollection in\nserver-mode or infinite-mode, a page of models is fetched after sorting is\ndone on the server.

    \n\n

    If the underlying collection is a Backbone.PageableCollection in\nclient-mode, or any\nBackbone.Collection instance, sorting\nis done on the client side. If the collection is an instance of a\nBackbone.PageableCollection, sorting will be done globally on all the pages\nand the current page will then be returned.

    \n\n

    Triggers a Backbone backgrid:sort event from the collection when done\nwith the column name, direction, comparator and a reference to the\ncollection.

    \n

    Parameters

    • columnName : string
      \n
    • direction : null|\"ascending\"|\"descending\"
      \n
    • comparator : function(*, *): number (optional)
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.HeaderCell

    HeaderCell is a special cell class that renders a column header cell. If the\ncolumn is sortable, a sorter is also rendered and will trigger a table\nrefresh after sorting.

    \n
    Defined By

    Properties

    Backgrid.HeaderCell
    _direction : null|\"ascending\"|\"descending\"

    The current sorting\ndirection of this column.

    \n

    The current sorting\ndirection of this column.

    \n
    Backgrid.HeaderCell
    : Object
    ...
    \n

    Defaults to: {"click a": "onClick"}

    Backgrid.HeaderCell
    : String
    ...
    \n

    Defaults to: "th"

    Defined By

    Methods

    Backgrid.HeaderCell
    ( left, right )private
    Default comparator for Backbone.Collections. ...

    Default comparator for Backbone.Collections. Sorts cids in ascending\norder. The cids of the models are assumed to be in insertion order.

    \n

    Parameters

    • left : *
      \n
    • right : *
      \n
    Backgrid.HeaderCell
    ( sortByColName, direction, comparator, collection )private
    Event handler for the Backbone backgrid:sort event. ...

    Event handler for the Backbone backgrid:sort event. Resets this cell's\ndirection to default if sorting is being done on another column.

    \n

    Parameters

    • sortByColName : Object
      \n
    • direction : Object
      \n
    • comparator : Object
      \n
    • collection : Object
      \n
    Backgrid.HeaderCell
    ( dir ) : null|string
    Gets or sets the direction of this cell. ...

    Gets or sets the direction of this cell. If called directly without\nparameters, returns the current direction of this cell, otherwise sets\nit. If a null is given, sets this cell back to the default order.

    \n

    Parameters

    • dir : null|\"ascending\"|\"descending\"
      \n

    Returns

    • null|string

      The current direction or the changed direction.

      \n
    Backgrid.HeaderCell
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If options.column or options.collection is undefined.

      \n
    Backgrid.HeaderCell
    ( e )
    Event handler for the click event on the cell's anchor. ...

    Event handler for the click event on the cell's anchor. If the column is\nsortable, clicking on the anchor will cycle through 3 sorting orderings -\nascending, descending, and default.

    \n

    Parameters

    • e : Object
      \n
    Backgrid.HeaderCell
    ( ) : Backgrid.HeaderCellchainable
    Renders a header cell with a sorter and a label. ...

    Renders a header cell with a sorter and a label.

    \n

    Returns

    Backgrid.HeaderCell
    ( columnName, direction, [comparator] )
    If the underlying collection is a Backbone.PageableCollection in\nserver-mode or infinite-mode, a page of models is fe...

    If the underlying collection is a Backbone.PageableCollection in\nserver-mode or infinite-mode, a page of models is fetched after sorting is\ndone on the server.

    \n\n

    If the underlying collection is a Backbone.PageableCollection in\nclient-mode, or any\nBackbone.Collection instance, sorting\nis done on the client side. If the collection is an instance of a\nBackbone.PageableCollection, sorting will be done globally on all the pages\nand the current page will then be returned.

    \n\n

    Triggers a Backbone backgrid:sort event from the collection when done\nwith the column name, direction, comparator and a reference to the\ncollection.

    \n

    Parameters

    • columnName : string
      \n
    • direction : null|\"ascending\"|\"descending\"
      \n
    • comparator : function(*, *): number (optional)
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.HeaderRow.js b/api/output/Backgrid.HeaderRow.js index d4ae560b..dd6859cf 100644 --- a/api/output/Backgrid.HeaderRow.js +++ b/api/output/Backgrid.HeaderRow.js @@ -40,6 +40,14 @@ Ext.data.JsonP.Backgrid_HeaderRow({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "initialize", "tagname": "method", @@ -86,7 +94,7 @@ Ext.data.JsonP.Backgrid_HeaderRow({ ] }, - "linenr": 204, + "linenr": 209, "files": [ { "filename": "header.js", @@ -117,7 +125,7 @@ Ext.data.JsonP.Backgrid_HeaderRow({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Row" ], "subclasses": [ @@ -129,5 +137,5 @@ Ext.data.JsonP.Backgrid_HeaderRow({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Row
    Backgrid.HeaderRow

    HeaderRow is a controller for a row of header cells.

    \n
    Defined By

    Properties

    ...
    \n

    Defaults to: "tr"

    Defined By

    Methods

    Backgrid.HeaderRow
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>
      • headerCell : Backgrid.HeaderCell (optional)

        Customized default\nHeaderCell for all the columns. Supply a HeaderCell class or instance to a\nthe headerCell key in a column definition for column-specific header\nrendering.

        \n

    Throws

    • TypeError

      If options.columns or options.collection is undefined.

      \n

    Overrides: Backgrid.Row.initialize

    ( column, options ) : Backgrid.Cellprotected
    Factory method for making a cell. ...

    Factory method for making a cell. Used by initialize internally. Override\nthis to provide an appropriate cell instance for a custom Row subclass.

    \n

    Parameters

    Returns

    Clean up this row and its cells. ...

    Clean up this row and its cells.

    \n

    Returns

    Renders a row of cells for this row's model. ...

    Renders a row of cells for this row's model.

    \n

    Returns

    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Row
    Backgrid.HeaderRow

    HeaderRow is a controller for a row of header cells.

    \n
    Defined By

    Properties

    ...
    \n

    Defaults to: "tr"

    Defined By

    Methods

    Backgrid.HeaderRow
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>
      • headerCell : Backgrid.HeaderCell (optional)

        Customized default\nHeaderCell for all the columns. Supply a HeaderCell class or instance to a\nthe headerCell key in a column definition for column-specific header\nrendering.

        \n

    Throws

    • TypeError

      If options.columns or options.collection is undefined.

      \n

    Overrides: Backgrid.Row.initialize

    ( column, options ) : Backgrid.Cellprotected
    Factory method for making a cell. ...

    Factory method for making a cell. Used by initialize internally. Override\nthis to provide an appropriate cell instance for a custom Row subclass.

    \n

    Parameters

    Returns

    Clean up this row and its cells. ...

    Clean up this row and its cells.

    \n

    Returns

    Renders a row of cells for this row's model. ...

    Renders a row of cells for this row's model.

    \n

    Returns

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.InputCellEditor.js b/api/output/Backgrid.InputCellEditor.js index c4f6fd78..5b8b4809 100644 --- a/api/output/Backgrid.InputCellEditor.js +++ b/api/output/Backgrid.InputCellEditor.js @@ -56,6 +56,14 @@ Ext.data.JsonP.Backgrid_InputCellEditor({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "initialize", "tagname": "method", @@ -132,7 +140,7 @@ Ext.data.JsonP.Backgrid_InputCellEditor({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.CellEditor" ], "subclasses": [ @@ -144,5 +152,5 @@ Ext.data.JsonP.Backgrid_InputCellEditor({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.CellEditor
    Backgrid.InputCellEditor

    InputCellEditor the cell editor type used by most core cell types. This cell\neditor renders a text input box as its editor. The input will render a\nplaceholder if the value is empty on supported browsers.

    \n
    Defined By

    Properties

    Backgrid.InputCellEditor
    : Object
    ...
    \n

    Defaults to: {type: "text"}

    Backgrid.InputCellEditor
    : Object
    ...
    \n

    Defaults to: {"blur": "saveOrCancel", "keydown": "saveOrCancel"}

    Backgrid.InputCellEditor
    : String
    ...
    \n

    Defaults to: "input"

    Defined By

    Methods

    Backgrid.InputCellEditor
    ( options )
    Initializer. ...

    Initializer. Removes this el from the DOM when a done event is\ntriggered.

    \n

    Parameters

    Overrides: Backgrid.CellEditor.initialize

    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.InputCellEditor
    ( ) : Backgrid.InputCellEditorchainable
    Renders a text input with the cell value formatted for display, if it\nexists. ...

    Renders a text input with the cell value formatted for display, if it\nexists.

    \n

    Returns

    Backgrid.InputCellEditor
    ( e )
    If the key pressed is enter, tab, up, or down, converts the value\nin the editor to a raw value for saving into the mo...

    If the key pressed is enter, tab, up, or down, converts the value\nin the editor to a raw value for saving into the model using the formatter.

    \n\n

    If the key pressed is esc the changes are undone.

    \n\n

    If the editor goes out of focus (blur) but the value is invalid, the\nevent is intercepted and cancelled so the cell remains in focus pending for\nfurther action. The changes are saved otherwise.

    \n\n

    Triggers a Backbone backgrid:edited event from the model when successful,\nand backgrid:error if the value cannot be converted. Classes listening to\nthe error event, usually the Cell classes, should respond appropriately,\nusually by rendering some kind of error feedback.

    \n

    Parameters

    • e : Event
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.CellEditor
    Backgrid.InputCellEditor

    InputCellEditor the cell editor type used by most core cell types. This cell\neditor renders a text input box as its editor. The input will render a\nplaceholder if the value is empty on supported browsers.

    \n
    Defined By

    Properties

    Backgrid.InputCellEditor
    : Object
    ...
    \n

    Defaults to: {type: "text"}

    Backgrid.InputCellEditor
    : Object
    ...
    \n

    Defaults to: {"blur": "saveOrCancel", "keydown": "saveOrCancel"}

    Backgrid.InputCellEditor
    : String
    ...
    \n

    Defaults to: "input"

    Defined By

    Methods

    Backgrid.InputCellEditor
    ( options )
    Initializer. ...

    Initializer. Removes this el from the DOM when a done event is\ntriggered.

    \n

    Parameters

    Overrides: Backgrid.CellEditor.initialize

    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.InputCellEditor
    ( ) : Backgrid.InputCellEditorchainable
    Renders a text input with the cell value formatted for display, if it\nexists. ...

    Renders a text input with the cell value formatted for display, if it\nexists.

    \n

    Returns

    Backgrid.InputCellEditor
    ( e )
    If the key pressed is enter, tab, up, or down, converts the value\nin the editor to a raw value for saving into the mo...

    If the key pressed is enter, tab, up, or down, converts the value\nin the editor to a raw value for saving into the model using the formatter.

    \n\n

    If the key pressed is esc the changes are undone.

    \n\n

    If the editor goes out of focus (blur) but the value is invalid, the\nevent is intercepted and cancelled so the cell remains in focus pending for\nfurther action. The changes are saved otherwise.

    \n\n

    Triggers a Backbone backgrid:edited event from the model when successful,\nand backgrid:error if the value cannot be converted. Classes listening to\nthe error event, usually the Cell classes, should respond appropriately,\nusually by rendering some kind of error feedback.

    \n

    Parameters

    • e : Event
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.IntegerCell.js b/api/output/Backgrid.IntegerCell.js index a78deb54..5fbd4692 100644 --- a/api/output/Backgrid.IntegerCell.js +++ b/api/output/Backgrid.IntegerCell.js @@ -96,6 +96,14 @@ Ext.data.JsonP.Backgrid_IntegerCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -157,7 +165,7 @@ Ext.data.JsonP.Backgrid_IntegerCell({ ] }, - "linenr": 441, + "linenr": 463, "files": [ { "filename": "cell.js", @@ -188,7 +196,7 @@ Ext.data.JsonP.Backgrid_IntegerCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell", "Backgrid.NumberCell" ], @@ -201,5 +209,5 @@ Ext.data.JsonP.Backgrid_IntegerCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View

    An IntegerCell is just a Backgrid.NumberCell with 0 decimals. If a floating\npoint number is supplied, the number is simply rounded the usual way when\ndisplayed.

    \n
    Defined By

    Properties

    Backgrid.IntegerCell
    : String
    ...
    \n

    Defaults to: "integer-cell"

    Overrides: Backgrid.NumberCell.className

    ...
    \n

    Defaults to: '.'

    Backgrid.IntegerCell
    : number
    Must be an integer. ...

    Must be an integer.

    \n

    Defaults to: 0

    Overrides: Backgrid.NumberCell.decimals

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: Backgrid.NumberFormatter

    Overrides: Backgrid.Cell.formatter

    ...
    \n

    Defaults to: ','

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializes this cell and the number formatter. ...

    Initializes this cell and the number formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    An IntegerCell is just a Backgrid.NumberCell with 0 decimals. If a floating\npoint number is supplied, the number is simply rounded the usual way when\ndisplayed.

    \n
    Defined By

    Properties

    Backgrid.IntegerCell
    : String
    ...
    \n

    Defaults to: "integer-cell"

    Overrides: Backgrid.NumberCell.className

    ...
    \n

    Defaults to: '.'

    Backgrid.IntegerCell
    : number
    Must be an integer. ...

    Must be an integer.

    \n

    Defaults to: 0

    Overrides: Backgrid.NumberCell.decimals

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: Backgrid.NumberFormatter

    Overrides: Backgrid.Cell.formatter

    ...
    \n

    Defaults to: ','

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializes this cell and the number formatter. ...

    Initializes this cell and the number formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.NumberCell.js b/api/output/Backgrid.NumberCell.js index d5f802b7..02014915 100644 --- a/api/output/Backgrid.NumberCell.js +++ b/api/output/Backgrid.NumberCell.js @@ -96,6 +96,14 @@ Ext.data.JsonP.Backgrid_NumberCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -157,7 +165,7 @@ Ext.data.JsonP.Backgrid_NumberCell({ ] }, - "linenr": 397, + "linenr": 419, "files": [ { "filename": "cell.js", @@ -188,7 +196,7 @@ Ext.data.JsonP.Backgrid_NumberCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell" ], "subclasses": [ @@ -200,5 +208,5 @@ Ext.data.JsonP.Backgrid_NumberCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell
    Backgrid.NumberCell

    Subclasses

    NumberCell is a generic cell that renders all numbers. Numbers are formatted\nusing a Backgrid.NumberFormatter.

    \n
    Defined By

    Properties

    Backgrid.NumberCell
    : String
    ...
    \n

    Defaults to: "number-cell"

    Backgrid.NumberCell
    : string
    ...
    \n

    Defaults to: '.'

    Backgrid.NumberCell
    : number
    Must be an integer. ...

    Must be an integer.

    \n

    Defaults to: 2

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Backgrid.NumberCell
    : Backgrid.CellFormatter
    ...
    \n

    Defaults to: Backgrid.NumberFormatter

    Overrides: Backgrid.Cell.formatter

    Backgrid.NumberCell
    : string
    ...
    \n

    Defaults to: ','

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.NumberCell
    ( options )
    Initializes this cell and the number formatter. ...

    Initializes this cell and the number formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.NumberCell

    Subclasses

    NumberCell is a generic cell that renders all numbers. Numbers are formatted\nusing a Backgrid.NumberFormatter.

    \n
    Defined By

    Properties

    Backgrid.NumberCell
    : String
    ...
    \n

    Defaults to: "number-cell"

    Backgrid.NumberCell
    : string
    ...
    \n

    Defaults to: '.'

    Backgrid.NumberCell
    : number
    Must be an integer. ...

    Must be an integer.

    \n

    Defaults to: 2

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Backgrid.NumberCell
    : Backgrid.CellFormatter
    ...
    \n

    Defaults to: Backgrid.NumberFormatter

    Overrides: Backgrid.Cell.formatter

    Backgrid.NumberCell
    : string
    ...
    \n

    Defaults to: ','

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.NumberCell
    ( options )
    Initializes this cell and the number formatter. ...

    Initializes this cell and the number formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Row.js b/api/output/Backgrid.Row.js index 49da5b28..58ccadd0 100644 --- a/api/output/Backgrid.Row.js +++ b/api/output/Backgrid.Row.js @@ -1,7 +1,7 @@ Ext.data.JsonP.Backgrid_Row({ "tagname": "class", "name": "Backgrid.Row", - "extends": "Backbone.View", + "extends": "Backgrid.View", "mixins": [ ], @@ -40,6 +40,14 @@ Ext.data.JsonP.Backgrid_Row({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "initialize", "tagname": "method", @@ -117,7 +125,7 @@ Ext.data.JsonP.Backgrid_Row({ }, "component": false, "superclasses": [ - "Backbone.View" + "Backgrid.View" ], "subclasses": [ "Backgrid.HeaderRow" @@ -128,5 +136,5 @@ Ext.data.JsonP.Backgrid_Row({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Row

    Subclasses

    Row is a simple container view that takes a model instance and a list of\ncolumn metadata describing how each of the model's attribute is to be\nrendered, and apply the appropriate cell to each attribute.

    \n
    Defined By

    Properties

    Backgrid.Row
    : String
    ...
    \n

    Defaults to: "tr"

    Defined By

    Methods

    Backgrid.Row
    ( options )
    Initializes a row view instance. ...

    Initializes a row view instance.

    \n

    Parameters

    • options : Object
      \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • model : Backbone.Model

        The model instance to render.

        \n

    Throws

    • TypeError

      If options.columns or options.model is undefined.

      \n
    Backgrid.Row
    ( column, options ) : Backgrid.Cellprotected
    Factory method for making a cell. ...

    Factory method for making a cell. Used by initialize internally. Override\nthis to provide an appropriate cell instance for a custom Row subclass.

    \n

    Parameters

    Returns

    Backgrid.Row
    ( ) : Backgrid.Rowchainable
    Clean up this row and its cells. ...

    Clean up this row and its cells.

    \n

    Returns

    Backgrid.Row
    ( ) : Backgrid.Rowchainable
    Renders a row of cells for this row's model. ...

    Renders a row of cells for this row's model.

    \n

    Returns

    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Row

    Subclasses

    Row is a simple container view that takes a model instance and a list of\ncolumn metadata describing how each of the model's attribute is to be\nrendered, and apply the appropriate cell to each attribute.

    \n
    Defined By

    Properties

    Backgrid.Row
    : String
    ...
    \n

    Defaults to: "tr"

    Defined By

    Methods

    Backgrid.Row
    ( options )
    Initializes a row view instance. ...

    Initializes a row view instance.

    \n

    Parameters

    • options : Object
      \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • model : Backbone.Model

        The model instance to render.

        \n

    Throws

    • TypeError

      If options.columns or options.model is undefined.

      \n
    Backgrid.Row
    ( column, options ) : Backgrid.Cellprotected
    Factory method for making a cell. ...

    Factory method for making a cell. Used by initialize internally. Override\nthis to provide an appropriate cell instance for a custom Row subclass.

    \n

    Parameters

    Returns

    Backgrid.Row
    ( ) : Backgrid.Rowchainable
    Clean up this row and its cells. ...

    Clean up this row and its cells.

    \n

    Returns

    Backgrid.Row
    ( ) : Backgrid.Rowchainable
    Renders a row of cells for this row's model. ...

    Renders a row of cells for this row's model.

    \n

    Returns

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.SelectCell.js b/api/output/Backgrid.SelectCell.js index 9c71fe88..f7e48439 100644 --- a/api/output/Backgrid.SelectCell.js +++ b/api/output/Backgrid.SelectCell.js @@ -80,6 +80,14 @@ Ext.data.JsonP.Backgrid_SelectCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -141,7 +149,7 @@ Ext.data.JsonP.Backgrid_SelectCell({ ] }, - "linenr": 800, + "linenr": 824, "files": [ { "filename": "cell.js", @@ -172,7 +180,7 @@ Ext.data.JsonP.Backgrid_SelectCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell" ], "subclasses": [ @@ -184,5 +192,5 @@ Ext.data.JsonP.Backgrid_SelectCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell
    Backgrid.SelectCell

    Subclasses

    SelectCell is also a different kind of cell in that upon going into edit mode\nthe cell renders a list of options for to pick from, as opposed to an input\nbox.

    \n\n

    SelectCell cannot be referenced by its string name when used in a column\ndefinition because requires an optionValues class attribute to be\ndefined. optionValues can either be a list of name-value pairs, to be\nrendered as options, or a list of object hashes which consist of a key name\nwhich is the option group name, and a key values which is a list of\nname-value pairs to be rendered as options under that option group.

    \n\n

    In addition, optionValues can also be a parameter-less function that\nreturns one of the above. If the options are static, it is recommended the\nreturned values to be memoized. _.memoize() is a good function to help with\nthat.

    \n\n

    Lastly, since this class uses the default CellFormatter, during display mode,\nthe raw model value is compared with the optionValues values using\nEcmascript's implicit type conversion rules. When exiting edit mode, no type\nconversion is performed when saving into the model. This behavior is not\nalways desirable when the value type is anything other than string. To\ncontrol type conversion on the client-side, you should subclass SelectCell to\nprovide a custom formatter or provide the formatter to your column\ndefinition.

    \n
    Defined By

    Properties

    Backgrid.SelectCell
    : String
    ...
    \n

    Defaults to: "select-cell"

    Backgrid.SelectCell
    editor : Object
    \n
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    Backgrid.SelectCell
    optionValues : Array.<Array>|Array.<{name: string, values: Array.<Array>}>
    \n
    \n
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.SelectCell
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If optionsValues is undefined.

      \n

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Backgrid.SelectCell
    ( ) : Backgrid.SelectCellchainable
    Renders the label using the raw value as key to look up from optionValues. ...

    Renders the label using the raw value as key to look up from optionValues.

    \n

    Returns

    Throws

    • TypeError

      If optionValues is malformed.

      \n

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.SelectCell

    Subclasses

    SelectCell is also a different kind of cell in that upon going into edit mode\nthe cell renders a list of options for to pick from, as opposed to an input\nbox.

    \n\n

    SelectCell cannot be referenced by its string name when used in a column\ndefinition because requires an optionValues class attribute to be\ndefined. optionValues can either be a list of name-value pairs, to be\nrendered as options, or a list of object hashes which consist of a key name\nwhich is the option group name, and a key values which is a list of\nname-value pairs to be rendered as options under that option group.

    \n\n

    In addition, optionValues can also be a parameter-less function that\nreturns one of the above. If the options are static, it is recommended the\nreturned values to be memoized. _.memoize() is a good function to help with\nthat.

    \n\n

    Lastly, since this class uses the default CellFormatter, during display mode,\nthe raw model value is compared with the optionValues values using\nEcmascript's implicit type conversion rules. When exiting edit mode, no type\nconversion is performed when saving into the model. This behavior is not\nalways desirable when the value type is anything other than string. To\ncontrol type conversion on the client-side, you should subclass SelectCell to\nprovide a custom formatter or provide the formatter to your column\ndefinition.

    \n
    Defined By

    Properties

    Backgrid.SelectCell
    : String
    ...
    \n

    Defaults to: "select-cell"

    Backgrid.SelectCell
    editor : Object
    \n
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    Backgrid.SelectCell
    optionValues : Array.<Array>|Array.<{name: string, values: Array.<Array>}>
    \n
    \n
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.SelectCell
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If optionsValues is undefined.

      \n

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Backgrid.SelectCell
    ( ) : Backgrid.SelectCellchainable
    Renders the label using the raw value as key to look up from optionValues. ...

    Renders the label using the raw value as key to look up from optionValues.

    \n

    Returns

    Throws

    • TypeError

      If optionValues is malformed.

      \n

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.SelectCellEditor.js b/api/output/Backgrid.SelectCellEditor.js index 4c1c676f..b183db43 100644 --- a/api/output/Backgrid.SelectCellEditor.js +++ b/api/output/Backgrid.SelectCellEditor.js @@ -56,6 +56,14 @@ Ext.data.JsonP.Backgrid_SelectCellEditor({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "close", "tagname": "method", @@ -109,7 +117,7 @@ Ext.data.JsonP.Backgrid_SelectCellEditor({ ] }, - "linenr": 681, + "linenr": 703, "files": [ { "filename": "cell.js", @@ -140,7 +148,7 @@ Ext.data.JsonP.Backgrid_SelectCellEditor({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.CellEditor" ], "subclasses": [ @@ -152,5 +160,5 @@ Ext.data.JsonP.Backgrid_SelectCellEditor({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.CellEditor
    Backgrid.SelectCellEditor

    Subclasses

    SelectCellEditor renders an HTML <select> fragment as the editor.

    \n
    Defined By

    Properties

    Backgrid.SelectCellEditor
    : Object
    ...
    \n

    Defaults to: {"change": "save", "blur": "close", "keydown": "close"}

    Backgrid.SelectCellEditor
    : String
    ...
    \n

    Defaults to: "select"

    Backgrid.SelectCellEditor
    template : function(Object, ?Object=): string
    \n
    \n
    Defined By

    Methods

    Backgrid.SelectCellEditor
    ( e )
    Triggers a backgrid:edited event from the model so the body can close\nthis editor. ...

    Triggers a backgrid:edited event from the model so the body can close\nthis editor.

    \n

    Parameters

    • e : Object
      \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.SelectCellEditor
    ( ) : Backgrid.SelectCellEditorchainable
    Renders the options if optionValues is a list of name-value pairs. ...

    Renders the options if optionValues is a list of name-value pairs. The\noptions are contained inside option groups if optionValues is a list of\nobject hashes. The name is rendered at the option text and the value is the\noption value. If optionValues is a function, it is called without a\nparameter.

    \n

    Returns

    Backgrid.SelectCellEditor
    ( e )
    Saves the value of the selected option to the model attribute. ...

    Saves the value of the selected option to the model attribute. Triggers a\nbackgrid:edited Backbone event from the model.

    \n

    Parameters

    • e : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.CellEditor
    Backgrid.SelectCellEditor

    Subclasses

    SelectCellEditor renders an HTML <select> fragment as the editor.

    \n
    Defined By

    Properties

    Backgrid.SelectCellEditor
    : Object
    ...
    \n

    Defaults to: {"change": "save", "blur": "close", "keydown": "close"}

    Backgrid.SelectCellEditor
    : String
    ...
    \n

    Defaults to: "select"

    Backgrid.SelectCellEditor
    template : function(Object, ?Object=): string
    \n
    \n
    Defined By

    Methods

    Backgrid.SelectCellEditor
    ( e )
    Triggers a backgrid:edited event from the model so the body can close\nthis editor. ...

    Triggers a backgrid:edited event from the model so the body can close\nthis editor.

    \n

    Parameters

    • e : Object
      \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.SelectCellEditor
    ( ) : Backgrid.SelectCellEditorchainable
    Renders the options if optionValues is a list of name-value pairs. ...

    Renders the options if optionValues is a list of name-value pairs. The\noptions are contained inside option groups if optionValues is a list of\nobject hashes. The name is rendered at the option text and the value is the\noption value. If optionValues is a function, it is called without a\nparameter.

    \n

    Returns

    Backgrid.SelectCellEditor
    ( e )
    Saves the value of the selected option to the model attribute. ...

    Saves the value of the selected option to the model attribute. Triggers a\nbackgrid:edited Backbone event from the model.

    \n

    Parameters

    • e : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.StringCell.js b/api/output/Backgrid.StringCell.js index d5866b8b..4bccc3d6 100644 --- a/api/output/Backgrid.StringCell.js +++ b/api/output/Backgrid.StringCell.js @@ -72,6 +72,14 @@ Ext.data.JsonP.Backgrid_StringCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -133,7 +141,7 @@ Ext.data.JsonP.Backgrid_StringCell({ ] }, - "linenr": 322, + "linenr": 340, "files": [ { "filename": "cell.js", @@ -164,7 +172,7 @@ Ext.data.JsonP.Backgrid_StringCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell" ], "subclasses": [ @@ -177,5 +185,5 @@ Ext.data.JsonP.Backgrid_StringCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell
    Backgrid.StringCell

    Subclasses

    StringCell displays HTML escaped strings and accepts anything typed in.

    \n
    Defined By

    Properties

    Backgrid.StringCell
    : String
    ...
    \n

    Defaults to: "string-cell"

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.StringCell

    Subclasses

    StringCell displays HTML escaped strings and accepts anything typed in.

    \n
    Defined By

    Properties

    Backgrid.StringCell
    : String
    ...
    \n

    Defaults to: "string-cell"

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.TimeCell.js b/api/output/Backgrid.TimeCell.js index 51940d8c..02b45868 100644 --- a/api/output/Backgrid.TimeCell.js +++ b/api/output/Backgrid.TimeCell.js @@ -96,6 +96,14 @@ Ext.data.JsonP.Backgrid_TimeCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -157,7 +165,7 @@ Ext.data.JsonP.Backgrid_TimeCell({ ] }, - "linenr": 542, + "linenr": 564, "files": [ { "filename": "cell.js", @@ -188,7 +196,7 @@ Ext.data.JsonP.Backgrid_TimeCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell", "Backgrid.DatetimeCell" ], @@ -201,5 +209,5 @@ Ext.data.JsonP.Backgrid_TimeCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View

    TimeCell is a Backgrid.DatetimeCell without the date part.

    \n
    Defined By

    Properties

    Backgrid.TimeCell
    : String
    ...
    \n

    Defaults to: "time-cell"

    Overrides: Backgrid.DatetimeCell.className

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: Backgrid.DatetimeFormatter

    Overrides: Backgrid.Cell.formatter

    Backgrid.TimeCell
    : Boolean
    ...
    \n

    Defaults to: false

    Overrides: Backgrid.DatetimeCell.includeDate

    ...
    \n

    Defaults to: false

    ...
    \n

    Defaults to: true

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializes this cell and the datetime formatter. ...

    Initializes this cell and the datetime formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    TimeCell is a Backgrid.DatetimeCell without the date part.

    \n
    Defined By

    Properties

    Backgrid.TimeCell
    : String
    ...
    \n

    Defaults to: "time-cell"

    Overrides: Backgrid.DatetimeCell.className

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: Backgrid.DatetimeFormatter

    Overrides: Backgrid.Cell.formatter

    Backgrid.TimeCell
    : Boolean
    ...
    \n

    Defaults to: false

    Overrides: Backgrid.DatetimeCell.includeDate

    ...
    \n

    Defaults to: false

    ...
    \n

    Defaults to: true

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializes this cell and the datetime formatter. ...

    Initializes this cell and the datetime formatter.

    \n

    Parameters

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.UriCell.js b/api/output/Backgrid.UriCell.js index 0c437bb3..34d52a89 100644 --- a/api/output/Backgrid.UriCell.js +++ b/api/output/Backgrid.UriCell.js @@ -72,6 +72,14 @@ Ext.data.JsonP.Backgrid_UriCell({ } ], "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + }, { "name": "enterEditMode", "tagname": "method", @@ -133,7 +141,7 @@ Ext.data.JsonP.Backgrid_UriCell({ ] }, - "linenr": 337, + "linenr": 355, "files": [ { "filename": "cell.js", @@ -164,7 +172,7 @@ Ext.data.JsonP.Backgrid_UriCell({ }, "component": false, "superclasses": [ - "Backbone.View", + "Backgrid.View", "Backgrid.Cell" ], "subclasses": [ @@ -176,5 +184,5 @@ Ext.data.JsonP.Backgrid_UriCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backbone.View
    Backgrid.Cell
    Backgrid.UriCell

    UriCell renders an HTML <a> anchor for the value and accepts URIs as user\ninput values. No type conversion or URL validation is done by the formatter\nof this cell. Users who need URL validation are encourage to subclass UriCell\nto take advantage of the parsing capabilities of the HTMLAnchorElement\navailable on HTML5-capable browsers or using a third-party library like\nURI.js.

    \n
    Defined By

    Properties

    Backgrid.UriCell
    : String
    ...
    \n

    Defaults to: "uri-cell"

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    UriCell renders an HTML <a> anchor for the value and accepts URIs as user\ninput values. No type conversion or URL validation is done by the formatter\nof this cell. Users who need URL validation are encourage to subclass UriCell\nto take advantage of the parsing capabilities of the HTMLAnchorElement\navailable on HTML5-capable browsers or using a third-party library like\nURI.js.

    \n
    Defined By

    Properties

    Backgrid.UriCell
    : String
    ...
    \n

    Defaults to: "uri-cell"

    The\ndefault editor for all cell instances of this class. ...

    The\ndefault editor for all cell instances of this class. This value must be a\nclass, it will be automatically instantiated upon entering edit mode.

    \n\n

    See Backgrid.CellEditor

    \n

    Defaults to: Backgrid.InputCellEditor

    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • ReferenceError

      If formatter is a string but a formatter class of\nsaid name cannot be found in the Backgrid module.

      \n
    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Render a text string in a table cell. ...

    Render a text string in a table cell. The text is converted from the\nmodel's raw value for this cell's column.

    \n

    Returns

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.View.js b/api/output/Backgrid.View.js new file mode 100644 index 00000000..a3e6596b --- /dev/null +++ b/api/output/Backgrid.View.js @@ -0,0 +1,107 @@ +Ext.data.JsonP.Backgrid_View({ + "tagname": "class", + "name": "Backgrid.View", + "extends": null, + "mixins": [ + + ], + "alternateClassNames": [ + + ], + "aliases": { + }, + "singleton": false, + "requires": [ + + ], + "uses": [ + + ], + "enum": null, + "override": null, + "inheritable": null, + "inheritdoc": null, + "meta": { + }, + "private": null, + "id": "class-Backgrid.View", + "members": { + "cfg": [ + + ], + "property": [ + + ], + "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.View", + "meta": { + }, + "id": "method-constructor" + } + ], + "event": [ + + ], + "css_var": [ + + ], + "css_mixin": [ + + ] + }, + "linenr": 155, + "files": [ + { + "filename": "preamble.js", + "href": null + } + ], + "html_meta": { + }, + "statics": { + "cfg": [ + + ], + "property": [ + + ], + "method": [ + + ], + "event": [ + + ], + "css_var": [ + + ], + "css_mixin": [ + + ] + }, + "component": false, + "superclasses": [ + + ], + "subclasses": [ + "Backgrid.Body", + "Backgrid.Cell", + "Backgrid.CellEditor", + "Backgrid.EmptyRow", + "Backgrid.Extension.SelectRowCell", + "Backgrid.Footer", + "Backgrid.Grid", + "Backgrid.Header", + "Backgrid.HeaderCell", + "Backgrid.Row" + ], + "mixedInto": [ + + ], + "parentMixins": [ + + ], + "html": "

    Subclasses

    \n
    Defined By

    Methods

    Backgrid.View
    new( ) : Backgrid.View
    ...
    \n

    Returns

    " +}); \ No newline at end of file diff --git a/categories.json b/categories.json index 1d50152d..37e3c930 100644 --- a/categories.json +++ b/categories.json @@ -49,6 +49,7 @@ }, { "name": "Others", "classes": [ + "Backgrid.View", "Backgrid.Command", "Backgrid.Grid", "Backgrid.Body", From 199f8be4d5e26891767523c7892486118579b688 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Mon, 29 Apr 2013 05:36:29 +0800 Subject: [PATCH 04/31] Update example in the main doc --- index.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index b9109fee..55ebc43f 100644 --- a/index.html +++ b/index.html @@ -296,7 +296,7 @@

    Grid

    }); // Render the grid and attach the root to your HTML document - $("#example-1-result").append(grid.render().$el); + $("#example-1-result").append(grid.render().el); // Fetch some countries from the url territories.fetch({reset: true}); @@ -376,7 +376,7 @@

    A More Complete Example

    // Render the grid var $example2 = $("#example-2-result"); - $example2.append(pageableGrid.render().$el) + $example2.append(pageableGrid.render().el) // Initialize the paginator var paginator = new Backgrid.Extension.Paginator({ @@ -385,7 +385,7 @@

    A More Complete Example

    }); // Render the paginator - $example2.append(paginator.render().$el); + $example2.append(paginator.render().el); // Initialize a client-side filter to filter on the client // mode pageable collection's cache. @@ -395,10 +395,12 @@

    A More Complete Example

    }); // Render the filter - $example2.prepend(filter.render().$el); + $example2.prepend(filter.render().el); // Add some space to the filter and move it to the right - filter.$el.css({float: "right", margin: "20px"}); + // filter.$el.css({float: "right", margin: "20px"}); + filter.el.style.cssFloat = "right"; + filter.el.style.margin = "20px"; // Fetch some data pageableTerritories.fetch({reset: true}); @@ -879,7 +881,7 @@

    Putting Things at The End of a Table

    var CaptionFooter = Backgrid.Footer.extend({ render: function () { - this.$el.html("<tr><td colspan='6'>Hello World!</td></tr>"); + this.el.innerHTML("<tr><td colspan='6'>Hello World!</td></tr>"); return this; } From 134cc7d9635321a8df4932ccd0a92fe4992ed82d Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Mon, 29 Apr 2013 06:06:34 +0800 Subject: [PATCH 05/31] Fix Backgrid.View's remove and empty --- src/preamble.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/preamble.js b/src/preamble.js index dfd47af6..f017b4ce 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -184,18 +184,14 @@ _.extend(View.prototype, Backbone.Events, { }, empty: function () { - if (this.$el) this.$el.remove(); - else { - var el = this.el; - while (el.hasChildNodes()) { - el.removeChild(el.firstChild); - } - } + var el = this.el; + while (el.firstChild) el.removeChild(el.firstChild); return this; }, remove: function() { - this.empty(); + if (this.$el) this.$el.remove(); + else if (this.el.parentNode) this.el.parentNode.removeChild(this.el); this.stopListening(); return this; }, From 22d096816dd6fc2e89cdb46e0b29f9b8f0387ca1 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Fri, 10 May 2013 22:32:31 +0800 Subject: [PATCH 06/31] Update api and lib, fix SelectCell merge conflict --- ... data-d01f2dc8b037d0f00a232a7939f15078.js} | 74 ++++++++- api/index.html | 9 +- api/output/Backgrid.BooleanCell.js | 2 +- api/output/Backgrid.BooleanCellEditor.js | 2 +- api/output/Backgrid.CellFormatter.js | 3 +- api/output/Backgrid.DateCell.js | 2 +- api/output/Backgrid.DatetimeCell.js | 2 +- api/output/Backgrid.DatetimeFormatter.js | 2 +- api/output/Backgrid.EmailCell.js | 2 +- api/output/Backgrid.EmailFormatter.js | 2 +- .../Backgrid.Extension.ClientSideFilter.js | 2 +- api/output/Backgrid.Extension.LunrFilter.js | 2 +- api/output/Backgrid.Extension.MomentCell.js | 2 +- .../Backgrid.Extension.MomentFormatter.js | 2 +- api/output/Backgrid.Extension.Paginator.js | 2 +- api/output/Backgrid.Extension.Select2Cell.js | 20 ++- api/output/Backgrid.Extension.TextCell.js | 2 +- .../Backgrid.Extension.TextareaEditor.js | 22 +-- api/output/Backgrid.IntegerCell.js | 2 +- api/output/Backgrid.NumberCell.js | 2 +- api/output/Backgrid.SelectCell.js | 22 ++- api/output/Backgrid.SelectCellEditor.js | 2 +- api/output/Backgrid.SelectFormatter.js | 114 +++++++++++++ api/output/Backgrid.StringCell.js | 2 +- api/output/Backgrid.StringFormatter.js | 2 +- api/output/Backgrid.TimeCell.js | 2 +- api/output/Backgrid.UriCell.js | 2 +- lib/backgrid.css | 4 +- lib/backgrid.js | 153 ++++++++++++------ lib/backgrid.min.css | 2 +- lib/backgrid.min.js | 2 +- lib/extensions/filter/backgrid-filter.js | 11 +- lib/extensions/filter/backgrid-filter.min.js | 2 +- .../moment-cell/backgrid-moment-cell.js | 34 +++- .../moment-cell/backgrid-moment-cell.min.js | 2 +- .../paginator/backgrid-paginator.js | 79 +++++---- .../paginator/backgrid-paginator.min.js | 2 +- .../select-all/backgrid-select-all.min.js | 2 +- .../text-cell/backgrid-text-cell.js | 58 ++++--- .../text-cell/backgrid-text-cell.min.js | 2 +- src/cell.js | 10 +- 41 files changed, 481 insertions(+), 186 deletions(-) rename api/{data-2a1b304990c839ee109c21c60334cf02.js => data-d01f2dc8b037d0f00a232a7939f15078.js} (97%) create mode 100644 api/output/Backgrid.SelectFormatter.js diff --git a/api/data-2a1b304990c839ee109c21c60334cf02.js b/api/data-d01f2dc8b037d0f00a232a7939f15078.js similarity index 97% rename from api/data-2a1b304990c839ee109c21c60334cf02.js rename to api/data-d01f2dc8b037d0f00a232a7939f15078.js index 23115ed3..70b0f620 100644 --- a/api/data-2a1b304990c839ee109c21c60334cf02.js +++ b/api/data-d01f2dc8b037d0f00a232a7939f15078.js @@ -217,6 +217,12 @@ Docs = { "private": null, "icon": "icon-class" }, + { + "name": "Backgrid.SelectFormatter", + "extends": "Backgrid.CellFormatter", + "private": null, + "icon": "icon-class" + }, { "name": "Backgrid.Grid", "extends": "Backgrid.View", @@ -1017,6 +1023,24 @@ Docs = { }, "sort": 3 }, + { + "name": "multiple", + "fullName": "Backgrid.SelectCell.multiple", + "icon": "icon-property", + "url": "#!/api/Backgrid.SelectCell-property-multiple", + "meta": { + }, + "sort": 3 + }, + { + "name": "formatter", + "fullName": "Backgrid.SelectCell.formatter", + "icon": "icon-property", + "url": "#!/api/Backgrid.SelectCell-property-formatter", + "meta": { + }, + "sort": 3 + }, { "name": "optionValues", "fullName": "Backgrid.SelectCell.optionValues", @@ -1026,6 +1050,15 @@ Docs = { }, "sort": 3 }, + { + "name": "delimiter", + "fullName": "Backgrid.SelectCell.delimiter", + "icon": "icon-property", + "url": "#!/api/Backgrid.SelectCell-property-delimiter", + "meta": { + }, + "sort": 3 + }, { "name": "initialize", "fullName": "Backgrid.SelectCell.initialize", @@ -1825,19 +1858,19 @@ Docs = { "sort": 3 }, { - "name": "save", - "fullName": "Backgrid.Extension.TextareaEditor.save", + "name": "saveOrCancel", + "fullName": "Backgrid.Extension.TextareaEditor.saveOrCancel", "icon": "icon-method", - "url": "#!/api/Backgrid.Extension.TextareaEditor-method-save", + "url": "#!/api/Backgrid.Extension.TextareaEditor-method-saveOrCancel", "meta": { }, "sort": 3 }, { - "name": "cancel", - "fullName": "Backgrid.Extension.TextareaEditor.cancel", - "icon": "icon-method", - "url": "#!/api/Backgrid.Extension.TextareaEditor-method-cancel", + "name": "clearError", + "fullName": "Backgrid.Extension.TextareaEditor.clearError", + "icon": "icon-property", + "url": "#!/api/Backgrid.Extension.TextareaEditor-property-clearError", "meta": { }, "sort": 3 @@ -2096,6 +2129,33 @@ Docs = { }, "sort": 3 }, + { + "name": "SelectFormatter", + "fullName": "Backgrid.SelectFormatter", + "icon": "icon-class", + "url": "#!/api/Backgrid.SelectFormatter", + "meta": { + }, + "sort": 1 + }, + { + "name": "constructor", + "fullName": "Backgrid.SelectFormatter.constructor", + "icon": "icon-method", + "url": "#!/api/Backgrid.SelectFormatter-method-constructor", + "meta": { + }, + "sort": 3 + }, + { + "name": "fromRaw", + "fullName": "Backgrid.SelectFormatter.fromRaw", + "icon": "icon-method", + "url": "#!/api/Backgrid.SelectFormatter-method-fromRaw", + "meta": { + }, + "sort": 3 + }, { "name": "Grid", "fullName": "Backgrid.Grid", diff --git a/api/index.html b/api/index.html index e02bee83..3ad6abc8 100644 --- a/api/index.html +++ b/api/index.html @@ -12,7 +12,7 @@ - + @@ -59,14 +59,15 @@

    Formatters

  • Backgrid.EmailFormatter
  • Backgrid.NumberFormatter
  • Backgrid.DatetimeFormatter
  • +
  • Backgrid.SelectFormatter
  • + + -

    Headers

    - + diff --git a/api/output/Backgrid.BooleanCell.js b/api/output/Backgrid.BooleanCell.js index c24ee0a4..13cf6ef0 100644 --- a/api/output/Backgrid.BooleanCell.js +++ b/api/output/Backgrid.BooleanCell.js @@ -141,7 +141,7 @@ Ext.data.JsonP.Backgrid_BooleanCell({ ] }, - "linenr": 666, + "linenr": 665, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.BooleanCellEditor.js b/api/output/Backgrid.BooleanCellEditor.js index a9b09355..e83ee94f 100644 --- a/api/output/Backgrid.BooleanCellEditor.js +++ b/api/output/Backgrid.BooleanCellEditor.js @@ -117,7 +117,7 @@ Ext.data.JsonP.Backgrid_BooleanCellEditor({ ] }, - "linenr": 580, + "linenr": 579, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.CellFormatter.js b/api/output/Backgrid.CellFormatter.js index cc1b64e5..19c66c7f 100644 --- a/api/output/Backgrid.CellFormatter.js +++ b/api/output/Backgrid.CellFormatter.js @@ -108,6 +108,7 @@ Ext.data.JsonP.Backgrid_CellFormatter({ "Backgrid.EmailFormatter", "Backgrid.Extension.MomentFormatter", "Backgrid.NumberFormatter", + "Backgrid.SelectFormatter", "Backgrid.StringFormatter" ], "mixedInto": [ @@ -116,5 +117,5 @@ Ext.data.JsonP.Backgrid_CellFormatter({ "parentMixins": [ ], - "html": "

    Subclasses

    Just a convenient class for interested parties to subclass.

    \n\n

    The default Cell classes don't require the formatter to be a subclass of\nFormatter as long as the fromRaw(rawData) and toRaw(formattedData) methods\nare defined.

    \n
    Defined By

    Methods

    Backgrid.CellFormatter
    new( ) : Backgrid.CellFormatter
    ...
    Backgrid.CellFormatter
    ( rawData ) : *
    Takes a raw value from a model and returns an optionally formatted string\nfor display. ...

    Takes a raw value from a model and returns an optionally formatted string\nfor display. The default implementation simply returns the supplied value\nas is without any type conversion.

    \n

    Parameters

    • rawData : *
      \n

    Returns

    • *
      \n
    Backgrid.CellFormatter
    ( formattedData ) : *|undefined
    Takes a formatted string, usually from user input, and returns a\nappropriately typed value for persistence in the model. ...

    Takes a formatted string, usually from user input, and returns a\nappropriately typed value for persistence in the model.

    \n\n

    If the user input is invalid or unable to be converted to a raw value\nsuitable for persistence in the model, toRaw must return undefined.

    \n

    Parameters

    • formattedData : string
      \n

    Returns

    • *|undefined
      \n
    " + "html": "

    Subclasses

    Just a convenient class for interested parties to subclass.

    \n\n

    The default Cell classes don't require the formatter to be a subclass of\nFormatter as long as the fromRaw(rawData) and toRaw(formattedData) methods\nare defined.

    \n
    Defined By

    Methods

    Backgrid.CellFormatter
    new( ) : Backgrid.CellFormatter
    ...
    Backgrid.CellFormatter
    ( rawData ) : *
    Takes a raw value from a model and returns an optionally formatted string\nfor display. ...

    Takes a raw value from a model and returns an optionally formatted string\nfor display. The default implementation simply returns the supplied value\nas is without any type conversion.

    \n

    Parameters

    • rawData : *
      \n

    Returns

    • *
      \n
    Backgrid.CellFormatter
    ( formattedData ) : *|undefined
    Takes a formatted string, usually from user input, and returns a\nappropriately typed value for persistence in the model. ...

    Takes a formatted string, usually from user input, and returns a\nappropriately typed value for persistence in the model.

    \n\n

    If the user input is invalid or unable to be converted to a raw value\nsuitable for persistence in the model, toRaw must return undefined.

    \n

    Parameters

    • formattedData : string
      \n

    Returns

    • *|undefined
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.DateCell.js b/api/output/Backgrid.DateCell.js index 4990d3b2..15dbd1ea 100644 --- a/api/output/Backgrid.DateCell.js +++ b/api/output/Backgrid.DateCell.js @@ -165,7 +165,7 @@ Ext.data.JsonP.Backgrid_DateCell({ ] }, - "linenr": 548, + "linenr": 547, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.DatetimeCell.js b/api/output/Backgrid.DatetimeCell.js index 4f0f865a..8bc0d731 100644 --- a/api/output/Backgrid.DatetimeCell.js +++ b/api/output/Backgrid.DatetimeCell.js @@ -165,7 +165,7 @@ Ext.data.JsonP.Backgrid_DatetimeCell({ ] }, - "linenr": 482, + "linenr": 481, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.DatetimeFormatter.js b/api/output/Backgrid.DatetimeFormatter.js index 1c2afdef..0c88122f 100644 --- a/api/output/Backgrid.DatetimeFormatter.js +++ b/api/output/Backgrid.DatetimeFormatter.js @@ -117,5 +117,5 @@ Ext.data.JsonP.Backgrid_DatetimeFormatter({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backgrid.CellFormatter
    Backgrid.DatetimeFormatter

    Formatter to converts between various datetime string formats.

    \n\n

    This class only understands ISO-8601 formatted datetime strings. See\nBackgrid.Extension.MomentFormatter if you need a much more flexible datetime\nformatter.

    \n
    Defined By

    Config options

    Backgrid.DatetimeFormatter
    : Object
    ...
    \n
    • includeDate : boolean (optional)

      Whether the values include the\ndate part.

      \n

      Defaults to: true

    • includeTime : boolean (optional)

      Whether the values include the\ntime part.

      \n

      Defaults to: true

    • includeMilli : boolean (optional)

      If includeTime is true,\nwhether to include the millisecond part, if it exists.

      \n

      Defaults to: false

    Defined By

    Methods

    Backgrid.DatetimeFormatter
    new( ) : Backgrid.DatetimeFormatter
    ...
    \n

    Returns

    Throws

    • Error

      If both includeDate and includeTime are false.

      \n

    Overrides: Backgrid.CellFormatter.constructor

    Backgrid.DatetimeFormatter
    ( rawData ) : string|null|undefined
    Converts an ISO-8601 formatted datetime string to a datetime string, date\nstring or a time string. ...

    Converts an ISO-8601 formatted datetime string to a datetime string, date\nstring or a time string. The timezone is ignored if supplied.

    \n

    Parameters

    • rawData : string
      \n

    Returns

    • string|null|undefined

      ISO-8601 string in UTC. Null and undefined\nvalues are returned as is.

      \n

    Overrides: Backgrid.CellFormatter.fromRaw

    Backgrid.DatetimeFormatter
    ( formattedData ) : string|undefined
    Converts an ISO-8601 formatted datetime string to a datetime string, date\nstring or a time string. ...

    Converts an ISO-8601 formatted datetime string to a datetime string, date\nstring or a time string. The timezone is ignored if supplied. This method\nparses the input values exactly the same way as\nBackgrid.Extension.MomentFormatter.fromRaw(), in addition to doing some\nsanity checks.

    \n

    Parameters

    • formattedData : string
      \n

    Returns

    • string|undefined

      ISO-8601 string in UTC. Undefined if a date is\nfound when includeDate is false, or a time is found when includeTime is\nfalse, or if includeDate is true and a date is not found, or if\nincludeTime is true and a time is not found.

      \n

    Overrides: Backgrid.CellFormatter.toRaw

    " + "html": "

    Hierarchy

    Backgrid.CellFormatter
    Backgrid.DatetimeFormatter

    Formatter to converts between various datetime formats.

    \n\n

    This class only understands ISO-8601 formatted datetime strings and UNIX\noffset (number of milliseconds since UNIX Epoch). See\nBackgrid.Extension.MomentFormatter if you need a much more flexible datetime\nformatter.

    \n
    Defined By

    Config options

    Backgrid.DatetimeFormatter
    : Object
    ...
    \n
    • includeDate : boolean (optional)

      Whether the values include the\ndate part.

      \n

      Defaults to: true

    • includeTime : boolean (optional)

      Whether the values include the\ntime part.

      \n

      Defaults to: true

    • includeMilli : boolean (optional)

      If includeTime is true,\nwhether to include the millisecond part, if it exists.

      \n

      Defaults to: false

    Defined By

    Methods

    Backgrid.DatetimeFormatter
    new( ) : Backgrid.DatetimeFormatter
    ...
    \n

    Returns

    Throws

    • Error

      If both includeDate and includeTime are false.

      \n

    Overrides: Backgrid.CellFormatter.constructor

    Backgrid.DatetimeFormatter
    ( rawData ) : string|null|undefined
    Converts an ISO-8601 formatted datetime string to a datetime string, date\nstring or a time string. ...

    Converts an ISO-8601 formatted datetime string to a datetime string, date\nstring or a time string. The timezone is ignored if supplied.

    \n

    Parameters

    • rawData : string
      \n

    Returns

    • string|null|undefined

      ISO-8601 string in UTC. Null and undefined\nvalues are returned as is.

      \n

    Overrides: Backgrid.CellFormatter.fromRaw

    Backgrid.DatetimeFormatter
    ( formattedData ) : string|undefined
    Converts an ISO-8601 formatted datetime string to a datetime string, date\nstring or a time string. ...

    Converts an ISO-8601 formatted datetime string to a datetime string, date\nstring or a time string. The timezone is ignored if supplied. This method\nparses the input values exactly the same way as\nBackgrid.Extension.MomentFormatter.fromRaw(), in addition to doing some\nsanity checks.

    \n

    Parameters

    • formattedData : string
      \n

    Returns

    • string|undefined

      ISO-8601 string in UTC. Undefined if a date is\nfound when includeDate is false, or a time is found when includeTime is\nfalse, or if includeDate is true and a date is not found, or if\nincludeTime is true and a time is not found.

      \n

    Overrides: Backgrid.CellFormatter.toRaw

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.EmailCell.js b/api/output/Backgrid.EmailCell.js index 368c9cbf..54591dbe 100644 --- a/api/output/Backgrid.EmailCell.js +++ b/api/output/Backgrid.EmailCell.js @@ -141,7 +141,7 @@ Ext.data.JsonP.Backgrid_EmailCell({ ] }, - "linenr": 388, + "linenr": 387, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.EmailFormatter.js b/api/output/Backgrid.EmailFormatter.js index 218df5a2..6c862876 100644 --- a/api/output/Backgrid.EmailFormatter.js +++ b/api/output/Backgrid.EmailFormatter.js @@ -68,7 +68,7 @@ Ext.data.JsonP.Backgrid_EmailFormatter({ ] }, - "linenr": 299, + "linenr": 307, "files": [ { "filename": "formatter.js", diff --git a/api/output/Backgrid.Extension.ClientSideFilter.js b/api/output/Backgrid.Extension.ClientSideFilter.js index c60d6ed5..70b80b16 100644 --- a/api/output/Backgrid.Extension.ClientSideFilter.js +++ b/api/output/Backgrid.Extension.ClientSideFilter.js @@ -148,7 +148,7 @@ Ext.data.JsonP.Backgrid_Extension_ClientSideFilter({ ] }, - "linenr": 98, + "linenr": 107, "files": [ { "filename": "backgrid-filter.js", diff --git a/api/output/Backgrid.Extension.LunrFilter.js b/api/output/Backgrid.Extension.LunrFilter.js index 006c0d87..34babcee 100644 --- a/api/output/Backgrid.Extension.LunrFilter.js +++ b/api/output/Backgrid.Extension.LunrFilter.js @@ -196,7 +196,7 @@ Ext.data.JsonP.Backgrid_Extension_LunrFilter({ ] }, - "linenr": 231, + "linenr": 240, "files": [ { "filename": "backgrid-filter.js", diff --git a/api/output/Backgrid.Extension.MomentCell.js b/api/output/Backgrid.Extension.MomentCell.js index 11ae72b9..6a232b0a 100644 --- a/api/output/Backgrid.Extension.MomentCell.js +++ b/api/output/Backgrid.Extension.MomentCell.js @@ -141,7 +141,7 @@ Ext.data.JsonP.Backgrid_Extension_MomentCell({ ] }, - "linenr": 102, + "linenr": 132, "files": [ { "filename": "backgrid-moment-cell.js", diff --git a/api/output/Backgrid.Extension.MomentFormatter.js b/api/output/Backgrid.Extension.MomentFormatter.js index 34094d26..7d8e950c 100644 --- a/api/output/Backgrid.Extension.MomentFormatter.js +++ b/api/output/Backgrid.Extension.MomentFormatter.js @@ -117,5 +117,5 @@ Ext.data.JsonP.Backgrid_Extension_MomentFormatter({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backgrid.CellFormatter
    Backgrid.Extension.MomentFormatter

    MomentFormatter converts bi-directionally any datetime values in any format\nsupported by moment() to any\ndatetime format\nmoment.fn.format()\nsupports.

    \n
    Defined By

    Config options

    Backgrid.Extension.MomentFormatter
    : Object
    ...
    \n
    • modelInUTC : boolean (optional)

      Whether the model values should\nbe read/written in UTC mode or local mode.

      \n

      Defaults to: true

    • modelLang : string (optional)

      The locale the model\nvalues should be read/written in.

      \n

      Defaults to: moment.lang()

    • modelFormat : string (optional)

      The format this\nmoment formatter should use to read/write model values. Only meaningful if\nthe values are strings.

      \n

      Defaults to: moment.defaultFormat

    • displayInUTC : boolean (optional)

      Whether the display values\nshould be read/written in UTC mode or local mode.

      \n

      Defaults to: true

    • displayLang : string (optional)

      The locale the display\nvalues should be read/written in.

      \n

      Defaults to: moment.lang()

    • displayFormat : string (optional)

      The format\nthis moment formatter should use to read/write dislay values.

      \n

      Defaults to: moment.defaultFormat

    Defined By

    Methods

    Backgrid.Extension.MomentFormatter
    ( rawData ) : string
    Converts datetime values from the model for display. ...

    Converts datetime values from the model for display.

    \n

    Parameters

    • rawData : *
      \n

    Returns

    • string
      \n

    Overrides: Backgrid.CellFormatter.fromRaw

    Backgrid.Extension.MomentFormatter
    ( formattedData ) : string
    Converts datetime values from user input to model values. ...

    Converts datetime values from user input to model values.

    \n

    Parameters

    • formattedData : string
      \n

    Returns

    • string
      \n

    Overrides: Backgrid.CellFormatter.toRaw

    " + "html": "

    Hierarchy

    Backgrid.CellFormatter
    Backgrid.Extension.MomentFormatter

    MomentFormatter converts bi-directionally any datetime values in any format\nsupported by moment() to any\ndatetime format\nmoment.fn.format()\nsupports.

    \n
    Defined By

    Config options

    Backgrid.Extension.MomentFormatter
    : Object
    ...
    \n
    • modelInUnixOffset : boolean (optional)

      Whether the model values\nshould be read/written as the number of milliseconds since UNIX Epoch.

      \n

      Defaults to: false

    • modelInUnixTimestamp : boolean (optional)

      Whether the model\nvalues should be read/written as the number of seconds since UNIX Epoch.

      \n

      Defaults to: false

    • modelInUTC : boolean (optional)

      Whether the model values should\nbe read/written in UTC mode or local mode.

      \n

      Defaults to: true

    • modelLang : string (optional)

      The locale the model\nvalues should be read/written in.

      \n

      Defaults to: moment.lang()

    • modelFormat : string (optional)

      The format this\nmoment formatter should use to read/write model values. Only meaningful if\nthe values are strings.

      \n

      Defaults to: moment.defaultFormat

    • displayInUnixOffset : boolean (optional)

      Whether the display\nvalues should be read/written as the number of milliseconds since UNIX\nEpoch.

      \n

      Defaults to: false

    • displayInUnixTimestamp : boolean (optional)

      Whether the display\nvalues should be read/written as the number of seconds since UNIX Epoch.

      \n

      Defaults to: false

    • displayInUTC : boolean (optional)

      Whether the display values\nshould be read/written in UTC mode or local mode.

      \n

      Defaults to: true

    • displayLang : string (optional)

      The locale the display\nvalues should be read/written in.

      \n

      Defaults to: moment.lang()

    • displayFormat : string (optional)

      The format\nthis moment formatter should use to read/write dislay values.

      \n

      Defaults to: moment.defaultFormat

    Defined By

    Methods

    Backgrid.Extension.MomentFormatter
    ( rawData ) : string
    Converts datetime values from the model for display. ...

    Converts datetime values from the model for display.

    \n

    Parameters

    • rawData : *
      \n

    Returns

    • string
      \n

    Overrides: Backgrid.CellFormatter.fromRaw

    Backgrid.Extension.MomentFormatter
    ( formattedData ) : string
    Converts datetime values from user input to model values. ...

    Converts datetime values from user input to model values.

    \n

    Parameters

    • formattedData : string
      \n

    Returns

    • string
      \n

    Overrides: Backgrid.CellFormatter.toRaw

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Extension.Paginator.js b/api/output/Backgrid.Extension.Paginator.js index 5b43e9cd..1f1157b4 100644 --- a/api/output/Backgrid.Extension.Paginator.js +++ b/api/output/Backgrid.Extension.Paginator.js @@ -158,5 +158,5 @@ Ext.data.JsonP.Backgrid_Extension_Paginator({ "parentMixins": [ ], - "html": "

    Paginator is a Backgrid extension that renders a series of configurable\npagination handles. This extension is best used for splitting a large data\nset across multiple pages. If the number of pages is larger then a\nthreshold, which is set to 10 by default, the page handles are rendered\nwithin a sliding window, plus the fast forward, fast backward, previous and\nnext page handles. The fast forward, fast backward, previous and next page\nhandles can be turned off.

    \n
    Defined By

    Properties

    Backgrid.Extension.Paginator
    : String
    ...
    \n

    Defaults to: "backgrid-paginator"

    Backgrid.Extension.Paginator
    : Object
    ...
    \n

    Defaults to: {"click a": "changePage"}

    Backgrid.Extension.Paginator
    : Object
    You can disable specific\nhandles by setting its value to null. ...

    You can disable specific\nhandles by setting its value to null.

    \n

    Defaults to: {first: "《", prev: "〈", next: "〉", last: "》"}

    Backgrid.Extension.Paginator
    template : Object
    \n
    \n
    Backgrid.Extension.Paginator
    : Number
    ...
    \n

    Defaults to: 10

    Defined By

    Methods

    Backgrid.Extension.Paginator
    ( e )
    jQuery event handler for the page handlers. ...

    jQuery event handler for the page handlers. Goes to the right page upon\nclicking.

    \n

    Parameters

    • e : Event
      \n
    Backgrid.Extension.Paginator
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • columns : Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>

        Column metadata.

        \n
      • collection : Backbone.Collection
      • fastForwardHandleLabels : boolean (optional)

        Whether to render fast forward buttons.

        \n
    Backgrid.Extension.Paginator
    ( ) : Array.<Object>
    Internal method to create a list of page handle objects for the template\nto render them. ...

    Internal method to create a list of page handle objects for the template\nto render them.

    \n

    Returns

    • Array.<Object>

      an array of page handle objects hashes

      \n
    Backgrid.Extension.Paginator
    ( ) : Backgrid.Extension.Paginatorchainable
    Render the paginator handles inside an unordered list placed inside a\ncell that spans all the columns. ...

    Render the paginator handles inside an unordered list placed inside a\ncell that spans all the columns.

    \n

    Returns

    " + "html": "

    Paginator is a Backgrid extension that renders a series of configurable\npagination handles. This extension is best used for splitting a large data\nset across multiple pages. If the number of pages is larger then a\nthreshold, which is set to 10 by default, the page handles are rendered\nwithin a sliding window, plus the fast forward, fast backward, previous and\nnext page handles. The fast forward, fast backward, previous and next page\nhandles can be turned off.

    \n
    Defined By

    Properties

    Backgrid.Extension.Paginator
    : String
    ...
    \n

    Defaults to: "backgrid-paginator"

    Backgrid.Extension.Paginator
    : Object
    ...
    \n

    Defaults to: {"click a": "changePage"}

    Backgrid.Extension.Paginator
    : Object
    You can disable specific\nhandles by setting its value to null. ...

    You can disable specific\nhandles by setting its value to null.

    \n

    Defaults to: {first: "《", prev: "〈", next: "〉", last: "》"}

    Backgrid.Extension.Paginator
    template : Object
    \n
    \n
    Backgrid.Extension.Paginator
    : Number
    ...
    \n

    Defaults to: 10

    Defined By

    Methods

    Backgrid.Extension.Paginator
    ( e )
    jQuery event handler for the page handlers. ...

    jQuery event handler for the page handlers. Goes to the right page upon\nclicking.

    \n

    Parameters

    • e : Event
      \n
    Backgrid.Extension.Paginator
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • collection : Backbone.Collection
      • fastForwardHandleLabels : boolean (optional)

        Whether to render fast forward buttons.

        \n
    Backgrid.Extension.Paginator
    ( ) : Array.<Object>
    Internal method to create a list of page handle objects for the template\nto render them. ...

    Internal method to create a list of page handle objects for the template\nto render them.

    \n

    Returns

    • Array.<Object>

      an array of page handle objects hashes

      \n
    Backgrid.Extension.Paginator
    ( ) : Backgrid.Extension.Paginatorchainable
    Render the paginator handles inside an unordered list. ...

    Render the paginator handles inside an unordered list.

    \n

    Returns

    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Extension.Select2Cell.js b/api/output/Backgrid.Extension.Select2Cell.js index ee8609da..695c3205 100644 --- a/api/output/Backgrid.Extension.Select2Cell.js +++ b/api/output/Backgrid.Extension.Select2Cell.js @@ -38,6 +38,14 @@ Ext.data.JsonP.Backgrid_Extension_Select2Cell({ }, "id": "property-className" }, + { + "name": "delimiter", + "tagname": "property", + "owner": "Backgrid.SelectCell", + "meta": { + }, + "id": "property-delimiter" + }, { "name": "editor", "tagname": "property", @@ -57,11 +65,19 @@ Ext.data.JsonP.Backgrid_Extension_Select2Cell({ { "name": "formatter", "tagname": "property", - "owner": "Backgrid.Cell", + "owner": "Backgrid.SelectCell", "meta": { }, "id": "property-formatter" }, + { + "name": "multiple", + "tagname": "property", + "owner": "Backgrid.SelectCell", + "meta": { + }, + "id": "property-multiple" + }, { "name": "optionValues", "tagname": "property", @@ -201,5 +217,5 @@ Ext.data.JsonP.Backgrid_Extension_Select2Cell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.SelectCell
    Backgrid.Extension.Select2Cell

    Select2Cell is a cell class that renders a select2 select box during edit\nmode.

    \n
    Defined By

    Properties

    Backgrid.Extension.Select2Cell
    : String
    ...
    \n

    Defaults to: "select2-cell"

    Overrides: Backgrid.SelectCell.className

    Backgrid.Extension.Select2Cell
    editor : Object
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    optionValues : Array.<Array>|Array.<{name: string, values: Array.<Array>}>
    \n
    \n
    Backgrid.Extension.Select2Cell
    select2Options : Object
    \n
    \n
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

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

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • model : Backbone.Model
      • column : Backgrid.Column
      • select2Options : Object (optional)

    Throws

    • TypeError

      If optionsValues is undefined.

      \n

    Overrides: Backgrid.SelectCell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Renders the label using the raw value as key to look up from optionValues. ...

    Renders the label using the raw value as key to look up from optionValues.

    \n

    Returns

    Throws

    • TypeError

      If optionValues is malformed.

      \n

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.SelectCell
    Backgrid.Extension.Select2Cell

    Select2Cell is a cell class that renders a select2 select box during edit\nmode.

    \n
    Defined By

    Properties

    Backgrid.Extension.Select2Cell
    : String
    ...
    \n

    Defaults to: "select2-cell"

    Overrides: Backgrid.SelectCell.className

    ...
    \n

    Defaults to: ', '

    Backgrid.Extension.Select2Cell
    editor : Object
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: false

    optionValues : Array.<Array>|Array.<{name: string, values: Array.<Array>}>
    \n
    \n
    Backgrid.Extension.Select2Cell
    select2Options : Object
    \n
    \n
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

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

    Initializer.

    \n

    Parameters

    • options : Object
      \n
      • model : Backbone.Model
      • column : Backgrid.Column
      • select2Options : Object (optional)

    Throws

    • TypeError

      If optionsValues is undefined.

      \n

    Overrides: Backgrid.SelectCell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Renders the label using the raw value as key to look up from optionValues. ...

    Renders the label using the raw value as key to look up from optionValues.

    \n

    Returns

    Throws

    • TypeError

      If optionValues is malformed.

      \n

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.Extension.TextCell.js b/api/output/Backgrid.Extension.TextCell.js index a4eddb68..e4e2b517 100644 --- a/api/output/Backgrid.Extension.TextCell.js +++ b/api/output/Backgrid.Extension.TextCell.js @@ -141,7 +141,7 @@ Ext.data.JsonP.Backgrid_Extension_TextCell({ ] }, - "linenr": 137, + "linenr": 143, "files": [ { "filename": "backgrid-text-cell.js", diff --git a/api/output/Backgrid.Extension.TextareaEditor.js b/api/output/Backgrid.Extension.TextareaEditor.js index 27219e12..987926d1 100644 --- a/api/output/Backgrid.Extension.TextareaEditor.js +++ b/api/output/Backgrid.Extension.TextareaEditor.js @@ -38,6 +38,14 @@ Ext.data.JsonP.Backgrid_Extension_TextareaEditor({ }, "id": "property-className" }, + { + "name": "clearError", + "tagname": "property", + "owner": "Backgrid.Extension.TextareaEditor", + "meta": { + }, + "id": "property-clearError" + }, { "name": "cols", "tagname": "property", @@ -96,14 +104,6 @@ Ext.data.JsonP.Backgrid_Extension_TextareaEditor({ }, "id": "method-constructor" }, - { - "name": "cancel", - "tagname": "method", - "owner": "Backgrid.Extension.TextareaEditor", - "meta": { - }, - "id": "method-cancel" - }, { "name": "close", "tagname": "method", @@ -147,12 +147,12 @@ Ext.data.JsonP.Backgrid_Extension_TextareaEditor({ "id": "method-render" }, { - "name": "save", + "name": "saveOrCancel", "tagname": "method", "owner": "Backgrid.Extension.TextareaEditor", "meta": { }, - "id": "method-save" + "id": "method-saveOrCancel" } ], "event": [ @@ -208,5 +208,5 @@ Ext.data.JsonP.Backgrid_Extension_TextareaEditor({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backgrid.View
    Backgrid.CellEditor
    Backgrid.Extension.TextareaEditor

    Renders a form with a text area and a save button in a modal dialog.

    \n
    Defined By

    Properties

    Backgrid.Extension.TextareaEditor
    : String
    ...
    \n

    Defaults to: "modal hide fade"

    Backgrid.Extension.TextareaEditor
    : Number
    ...
    \n

    Defaults to: 80

    Backgrid.Extension.TextareaEditor
    : Object
    ...
    \n

    Defaults to: {"submit": "save", "hide": "cancel", "hidden": "close", "shown": "focus"}

    Backgrid.Extension.TextareaEditor
    : Object
    The options passed to Bootstrap's modal\nplugin. ...

    The options passed to Bootstrap's modal\nplugin.

    \n

    Defaults to: {backdrop: false}

    Backgrid.Extension.TextareaEditor
    : Number
    ...
    \n

    Defaults to: 10

    Backgrid.Extension.TextareaEditor
    : String
    ...
    \n

    Defaults to: "div"

    Backgrid.Extension.TextareaEditor
    template : function(Object, ?Object=): string
    \n
    \n
    Defined By

    Methods

    Backgrid.Extension.TextareaEditor
    ( e )
    Event handler. ...

    Event handler. Revert the text in the model after asking for confirmation\nif dirty, otherwise just close the editor.

    \n

    Parameters

    • e : Event
      \n
    Backgrid.Extension.TextareaEditor
    ( e )
    Triggers a backgrid:edited event along with the cell editor as the\nparameter after the modal is hidden. ...

    Triggers a backgrid:edited event along with the cell editor as the\nparameter after the modal is hidden.

    \n

    Parameters

    • e : Event
      \n
    Backgrid.Extension.TextareaEditor
    ( )
    Focuses the textarea when the modal is shown. ...

    Focuses the textarea when the modal is shown.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.Extension.TextareaEditor
    ( ) : Backgrid.Extension.TextareaEditorchainable
    Renders a modal form dialog with a textarea, submit button and a close button. ...

    Renders a modal form dialog with a textarea, submit button and a close button.

    \n

    Returns

    Backgrid.Extension.TextareaEditor
    ( e )
    Event handler. ...

    Event handler. Saves the text in the text area to the model.

    \n\n

    Triggers a Backbone backgrid:error event along with the editor as the\nparameter if the value cannot be converted. Classes listening to the\nbackgrid:error event, usually the Cell classes, should respond\nappropriately, usually by rendering some kind of error feedback.

    \n

    Parameters

    • e : Event
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.CellEditor
    Backgrid.Extension.TextareaEditor

    Renders a form with a text area and a save button in a modal dialog.

    \n
    Defined By

    Properties

    Backgrid.Extension.TextareaEditor
    : String
    ...
    \n

    Defaults to: "modal hide fade"

    Backgrid.Extension.TextareaEditor
    clearError : Object

    Clears the error class on the parent cell.

    \n

    Clears the error class on the parent cell.

    \n
    Backgrid.Extension.TextareaEditor
    : Number
    ...
    \n

    Defaults to: 80

    Backgrid.Extension.TextareaEditor
    : Object
    ...
    \n

    Defaults to: {"keydown textarea": "clearError", "submit": "saveOrCancel", "hide": "saveOrCancel", "hidden": "close", "shown": "focus"}

    Backgrid.Extension.TextareaEditor
    : Object
    The options passed to Bootstrap's modal\nplugin. ...

    The options passed to Bootstrap's modal\nplugin.

    \n

    Defaults to: {backdrop: false}

    Backgrid.Extension.TextareaEditor
    : Number
    ...
    \n

    Defaults to: 10

    Backgrid.Extension.TextareaEditor
    : String
    ...
    \n

    Defaults to: "div"

    Backgrid.Extension.TextareaEditor
    template : function(Object, ?Object=): string
    \n
    \n
    Defined By

    Methods

    Backgrid.Extension.TextareaEditor
    ( e )
    Triggers a backgrid:edited event along with the cell editor as the\nparameter after the modal is hidden. ...

    Triggers a backgrid:edited event along with the cell editor as the\nparameter after the modal is hidden.

    \n

    Parameters

    • e : Event
      \n
    Backgrid.Extension.TextareaEditor
    ( )
    Focuses the textarea when the modal is shown. ...

    Focuses the textarea when the modal is shown.

    \n
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If formatter is not a formatter instance, or when\nmodel or column are undefined.

      \n
    Post-rendering setup and initialization. ...

    Post-rendering setup and initialization. Focuses the cell editor's el in\nthis default implementation. Should be called by Cell classes after\ncalling Backgrid.CellEditor#render.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n

    Returns

    Backgrid.Extension.TextareaEditor
    ( ) : Backgrid.Extension.TextareaEditorchainable
    Renders a modal form dialog with a textarea, submit button and a close button. ...

    Renders a modal form dialog with a textarea, submit button and a close button.

    \n

    Returns

    Backgrid.Extension.TextareaEditor
    ( e )
    Event handler. ...

    Event handler. Saves the text in the text area to the model when\nsubmitting. When cancelling, if the text area is dirty, a confirmation\ndialog will pop up. If the user clicks confirm, the text will be saved to\nthe model.

    \n\n

    Triggers a Backbone backgrid:error event from the model along with the\nmodel, column and the existing value as the parameters if the value\ncannot be converted.

    \n

    Parameters

    • e : Event
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.IntegerCell.js b/api/output/Backgrid.IntegerCell.js index 5fbd4692..49617279 100644 --- a/api/output/Backgrid.IntegerCell.js +++ b/api/output/Backgrid.IntegerCell.js @@ -165,7 +165,7 @@ Ext.data.JsonP.Backgrid_IntegerCell({ ] }, - "linenr": 463, + "linenr": 462, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.NumberCell.js b/api/output/Backgrid.NumberCell.js index 02014915..42ce0166 100644 --- a/api/output/Backgrid.NumberCell.js +++ b/api/output/Backgrid.NumberCell.js @@ -165,7 +165,7 @@ Ext.data.JsonP.Backgrid_NumberCell({ ] }, - "linenr": 419, + "linenr": 418, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.SelectCell.js b/api/output/Backgrid.SelectCell.js index f7e48439..c05ae440 100644 --- a/api/output/Backgrid.SelectCell.js +++ b/api/output/Backgrid.SelectCell.js @@ -38,6 +38,14 @@ Ext.data.JsonP.Backgrid_SelectCell({ }, "id": "property-className" }, + { + "name": "delimiter", + "tagname": "property", + "owner": "Backgrid.SelectCell", + "meta": { + }, + "id": "property-delimiter" + }, { "name": "editor", "tagname": "property", @@ -57,11 +65,19 @@ Ext.data.JsonP.Backgrid_SelectCell({ { "name": "formatter", "tagname": "property", - "owner": "Backgrid.Cell", + "owner": "Backgrid.SelectCell", "meta": { }, "id": "property-formatter" }, + { + "name": "multiple", + "tagname": "property", + "owner": "Backgrid.SelectCell", + "meta": { + }, + "id": "property-multiple" + }, { "name": "optionValues", "tagname": "property", @@ -149,7 +165,7 @@ Ext.data.JsonP.Backgrid_SelectCell({ ] }, - "linenr": 824, + "linenr": 832, "files": [ { "filename": "cell.js", @@ -192,5 +208,5 @@ Ext.data.JsonP.Backgrid_SelectCell({ "parentMixins": [ ], - "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.SelectCell

    Subclasses

    SelectCell is also a different kind of cell in that upon going into edit mode\nthe cell renders a list of options for to pick from, as opposed to an input\nbox.

    \n\n

    SelectCell cannot be referenced by its string name when used in a column\ndefinition because requires an optionValues class attribute to be\ndefined. optionValues can either be a list of name-value pairs, to be\nrendered as options, or a list of object hashes which consist of a key name\nwhich is the option group name, and a key values which is a list of\nname-value pairs to be rendered as options under that option group.

    \n\n

    In addition, optionValues can also be a parameter-less function that\nreturns one of the above. If the options are static, it is recommended the\nreturned values to be memoized. _.memoize() is a good function to help with\nthat.

    \n\n

    Lastly, since this class uses the default CellFormatter, during display mode,\nthe raw model value is compared with the optionValues values using\nEcmascript's implicit type conversion rules. When exiting edit mode, no type\nconversion is performed when saving into the model. This behavior is not\nalways desirable when the value type is anything other than string. To\ncontrol type conversion on the client-side, you should subclass SelectCell to\nprovide a custom formatter or provide the formatter to your column\ndefinition.

    \n
    Defined By

    Properties

    Backgrid.SelectCell
    : String
    ...
    \n

    Defaults to: "select-cell"

    Backgrid.SelectCell
    editor : Object
    \n
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    ...
    \n

    Defaults to: new CellFormatter()

    Backgrid.SelectCell
    optionValues : Array.<Array>|Array.<{name: string, values: Array.<Array>}>
    \n
    \n
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.SelectCell
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If optionsValues is undefined.

      \n

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Backgrid.SelectCell
    ( ) : Backgrid.SelectCellchainable
    Renders the label using the raw value as key to look up from optionValues. ...

    Renders the label using the raw value as key to look up from optionValues.

    \n

    Returns

    Throws

    • TypeError

      If optionValues is malformed.

      \n

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " + "html": "

    Hierarchy

    Backgrid.View
    Backgrid.Cell
    Backgrid.SelectCell

    Subclasses

    SelectCell is also a different kind of cell in that upon going into edit mode\nthe cell renders a list of options to pick from, as opposed to an input box.

    \n\n

    SelectCell cannot be referenced by its string name when used in a column\ndefinition because it requires an optionValues class attribute to be\ndefined. optionValues can either be a list of name-value pairs, to be\nrendered as options, or a list of object hashes which consist of a key name\nwhich is the option group name, and a key values which is a list of\nname-value pairs to be rendered as options under that option group.

    \n\n

    In addition, optionValues can also be a parameter-less function that\nreturns one of the above. If the options are static, it is recommended the\nreturned values to be memoized. _.memoize() is a good function to help with\nthat.

    \n\n

    During display mode, the default formatter will normalize the raw model value\nto an array of values whether the raw model value is a scalar or an\narray. Each value is compared with the optionValues values using\nEcmascript's implicit type conversion rules. When exiting edit mode, no type\nconversion is performed when saving into the model. This behavior is not\nalways desirable when the value type is anything other than string. To\ncontrol type conversion on the client-side, you should subclass SelectCell to\nprovide a custom formatter or provide the formatter to your column\ndefinition.

    \n\n

    See:\n $.fn.val()

    \n
    Defined By

    Properties

    Backgrid.SelectCell
    : String
    ...
    \n

    Defaults to: "select-cell"

    Backgrid.SelectCell
    : String
    ...
    \n

    Defaults to: ', '

    Backgrid.SelectCell
    editor : Object
    \n
    ...
    \n

    Defaults to: {"click": "enterEditMode"}

    Backgrid.SelectCell
    formatter : Object
    Backgrid.SelectCell
    : Boolean
    ...
    \n

    Defaults to: false

    Backgrid.SelectCell
    optionValues : Array.<Array>|Array.<{name: string, values: Array.<Array>}>
    \n
    \n
    ...
    \n

    Defaults to: "td"

    Defined By

    Methods

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. ...

    If this column is editable, a new CellEditor instance is instantiated with\nits required parameters. An editor CSS class is added to the cell upon\nentering edit mode.

    \n\n

    This method triggers a Backbone backgrid:edit event from the model when\nthe cell is entering edit mode and an editor instance has been constructed,\nbut before it is rendered and inserted into the DOM. The cell and the\nconstructed cell editor instance are sent as event parameters when this\nevent is triggered.

    \n\n

    When this cell has finished switching to edit mode, a Backbone\nbackgrid:editing event is triggered from the model. The cell and the\nconstructed cell instance are also sent as parameters in the event.

    \n\n

    When the model triggers a backgrid:error event, it means the editor is\nunable to convert the current user input to an apprpriate value for the\nmodel's column, and an error CSS class is added to the cell accordingly.

    \n
    Removes the editor and re-render in display mode. ...

    Removes the editor and re-render in display mode.

    \n
    Backgrid.SelectCell
    ( options )
    Initializer. ...

    Initializer.

    \n

    Parameters

    Throws

    • TypeError

      If optionsValues is undefined.

      \n

    Overrides: Backgrid.Cell.initialize

    Clean up this cell. ...

    Clean up this cell.

    \n

    Returns

    Backgrid.SelectCell
    ( ) : Backgrid.SelectCellchainable
    Renders the label using the raw value as key to look up from optionValues. ...

    Renders the label using the raw value as key to look up from optionValues.

    \n

    Returns

    Throws

    • TypeError

      If optionValues is malformed.

      \n

    Overrides: Backgrid.Cell.render

    ( model, column )
    Put an error CSS class on the table cell. ...

    Put an error CSS class on the table cell.

    \n

    Parameters

    • model : Object
      \n
    • column : Object
      \n
    " }); \ No newline at end of file diff --git a/api/output/Backgrid.SelectCellEditor.js b/api/output/Backgrid.SelectCellEditor.js index b183db43..c5fd4662 100644 --- a/api/output/Backgrid.SelectCellEditor.js +++ b/api/output/Backgrid.SelectCellEditor.js @@ -117,7 +117,7 @@ Ext.data.JsonP.Backgrid_SelectCellEditor({ ] }, - "linenr": 703, + "linenr": 702, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.SelectFormatter.js b/api/output/Backgrid.SelectFormatter.js new file mode 100644 index 00000000..28f9afd2 --- /dev/null +++ b/api/output/Backgrid.SelectFormatter.js @@ -0,0 +1,114 @@ +Ext.data.JsonP.Backgrid_SelectFormatter({ + "tagname": "class", + "name": "Backgrid.SelectFormatter", + "extends": "Backgrid.CellFormatter", + "mixins": [ + + ], + "alternateClassNames": [ + + ], + "aliases": { + }, + "singleton": false, + "requires": [ + + ], + "uses": [ + + ], + "enum": null, + "override": null, + "inheritable": null, + "inheritdoc": null, + "meta": { + }, + "private": null, + "id": "class-Backgrid.SelectFormatter", + "members": { + "cfg": [ + + ], + "property": [ + + ], + "method": [ + { + "name": "constructor", + "tagname": "method", + "owner": "Backgrid.SelectFormatter", + "meta": { + }, + "id": "method-constructor" + }, + { + "name": "fromRaw", + "tagname": "method", + "owner": "Backgrid.SelectFormatter", + "meta": { + }, + "id": "method-fromRaw" + }, + { + "name": "toRaw", + "tagname": "method", + "owner": "Backgrid.CellFormatter", + "meta": { + }, + "id": "method-toRaw" + } + ], + "event": [ + + ], + "css_var": [ + + ], + "css_mixin": [ + + ] + }, + "linenr": 334, + "files": [ + { + "filename": "formatter.js", + "href": null + } + ], + "html_meta": { + }, + "statics": { + "cfg": [ + + ], + "property": [ + + ], + "method": [ + + ], + "event": [ + + ], + "css_var": [ + + ], + "css_mixin": [ + + ] + }, + "component": false, + "superclasses": [ + "Backgrid.CellFormatter" + ], + "subclasses": [ + + ], + "mixedInto": [ + + ], + "parentMixins": [ + + ], + "html": "

    Hierarchy

    Backgrid.CellFormatter
    Backgrid.SelectFormatter

    Formatter for SelectCell.

    \n
    Defined By

    Methods

    Backgrid.SelectFormatter
    ( rawValue ) : Array.<*>
    Normalizes raw scalar or array values to an array. ...

    Normalizes raw scalar or array values to an array.

    \n

    Parameters

    • rawValue : *
      \n

    Returns

    • Array.<*>
      \n

    Overrides: Backgrid.CellFormatter.fromRaw

    ( formattedData ) : *|undefined
    Takes a formatted string, usually from user input, and returns a\nappropriately typed value for persistence in the model. ...

    Takes a formatted string, usually from user input, and returns a\nappropriately typed value for persistence in the model.

    \n\n

    If the user input is invalid or unable to be converted to a raw value\nsuitable for persistence in the model, toRaw must return undefined.

    \n

    Parameters

    • formattedData : string
      \n

    Returns

    • *|undefined
      \n
    " +}); \ No newline at end of file diff --git a/api/output/Backgrid.StringCell.js b/api/output/Backgrid.StringCell.js index 4bccc3d6..fde924e3 100644 --- a/api/output/Backgrid.StringCell.js +++ b/api/output/Backgrid.StringCell.js @@ -141,7 +141,7 @@ Ext.data.JsonP.Backgrid_StringCell({ ] }, - "linenr": 340, + "linenr": 339, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.StringFormatter.js b/api/output/Backgrid.StringFormatter.js index af4b7155..06a0f5e1 100644 --- a/api/output/Backgrid.StringFormatter.js +++ b/api/output/Backgrid.StringFormatter.js @@ -68,7 +68,7 @@ Ext.data.JsonP.Backgrid_StringFormatter({ ] }, - "linenr": 274, + "linenr": 282, "files": [ { "filename": "formatter.js", diff --git a/api/output/Backgrid.TimeCell.js b/api/output/Backgrid.TimeCell.js index 02b45868..793ef49c 100644 --- a/api/output/Backgrid.TimeCell.js +++ b/api/output/Backgrid.TimeCell.js @@ -165,7 +165,7 @@ Ext.data.JsonP.Backgrid_TimeCell({ ] }, - "linenr": 564, + "linenr": 563, "files": [ { "filename": "cell.js", diff --git a/api/output/Backgrid.UriCell.js b/api/output/Backgrid.UriCell.js index 34d52a89..e10debde 100644 --- a/api/output/Backgrid.UriCell.js +++ b/api/output/Backgrid.UriCell.js @@ -141,7 +141,7 @@ Ext.data.JsonP.Backgrid_UriCell({ ] }, - "linenr": 355, + "linenr": 354, "files": [ { "filename": "cell.js", diff --git a/lib/backgrid.css b/lib/backgrid.css index d9bf787e..8aaa3847 100644 --- a/lib/backgrid.css +++ b/lib/backgrid.css @@ -110,8 +110,8 @@ -moz-appearance: none; } -.backgrid td.editor.error, -.backgrid tbody tr:nth-child(odd) td.editor.error { +.backgrid td.error, +.backgrid tbody tr:nth-child(odd) td.error { background-color: rgba(255, 210, 77, 0.1); outline: 1px solid #ffd24d; } diff --git a/lib/backgrid.js b/lib/backgrid.js index f8227b1a..94aa7766 100644 --- a/lib/backgrid.js +++ b/lib/backgrid.js @@ -57,7 +57,7 @@ function lpad(str, length, padstr) { var Backgrid = root.Backgrid = { - VERSION: "0.2.5", + VERSION: "0.2.6", Extension: {}, @@ -194,18 +194,14 @@ _.extend(View.prototype, Backbone.Events, { }, empty: function () { - if (this.$el) this.$el.remove(); - else { - var el = this.el; - while (el.hasChildNodes()) { - el.removeChild(el.firstChild); - } - } + var el = this.el; + while (el.firstChild) el.removeChild(el.firstChild); return this; }, remove: function() { - this.empty(); + if (this.$el) this.$el.remove(); + else if (this.el.parentNode) this.el.parentNode.removeChild(this.el); this.stopListening(); return this; }, @@ -454,9 +450,10 @@ _.extend(NumberFormatter.prototype, { }); /** - Formatter to converts between various datetime string formats. + Formatter to converts between various datetime formats. - This class only understands ISO-8601 formatted datetime strings. See + This class only understands ISO-8601 formatted datetime strings and UNIX + offset (number of milliseconds since UNIX Epoch). See Backgrid.Extension.MomentFormatter if you need a much more flexible datetime formatter. @@ -501,11 +498,18 @@ _.extend(DatetimeFormatter.prototype, { ISO_SPLITTER_RE: /T|Z| +/, _convert: function (data, validate) { - data = data.trim(); - var parts = data.split(this.ISO_SPLITTER_RE) || []; - - var date = this.DATE_RE.test(parts[0]) ? parts[0] : ''; - var time = date && parts[1] ? parts[1] : this.TIME_RE.test(parts[0]) ? parts[0] : ''; + var date, time = null; + if (_.isNumber(data)) { + var jsDate = new Date(data); + date = lpad(jsDate.getUTCFullYear(), 4, 0) + '-' + lpad(jsDate.getUTCMonth() + 1, 2, 0) + '-' + lpad(jsDate.getUTCDate(), 2, 0); + time = lpad(jsDate.getUTCHours(), 2, 0) + ':' + lpad(jsDate.getUTCMinutes(), 2, 0) + ':' + lpad(jsDate.getUTCSeconds(), 2, 0); + } + else { + data = data.trim(); + var parts = data.split(this.ISO_SPLITTER_RE) || []; + date = this.DATE_RE.test(parts[0]) ? parts[0] : ''; + time = date && parts[1] ? parts[1] : this.TIME_RE.test(parts[0]) ? parts[0] : ''; + } var YYYYMMDD = this.DATE_RE.exec(date) || []; var HHmmssSSS = this.TIME_RE.exec(time) || []; @@ -631,6 +635,30 @@ _.extend(EmailFormatter.prototype, { } } }); + +/** + Formatter for SelectCell. + + @class Backgrid.SelectFormatter + @extends Backgrid.CellFormatter + @constructor +*/ +var SelectFormatter = Backgrid.SelectFormatter = function () {}; +SelectFormatter.prototype = new CellFormatter(); +_.extend(SelectFormatter.prototype, { + + /** + Normalizes raw scalar or array values to an array. + + @member Backgrid.SelectFormatter + @param {*} rawValue + @return {Array.<*>} + */ + fromRaw: function (rawValue) { + return _.isArray(rawValue) ? rawValue : rawValue != null ? [rawValue] : []; + } +}); + /* backgrid http://github.com/wyuenho/backgrid @@ -864,6 +892,7 @@ var Cell = Backgrid.Cell = Backgrid.View.extend({ this.listenTo(this.model, "change:" + this.column.get("name"), function () { if (!this.el.classList.contains("editor")) this.render(); }); + this.listenTo(this.model, "backgrid:error", this.renderError); }, show: function () { @@ -921,8 +950,6 @@ var Cell = Backgrid.Cell = Backgrid.View.extend({ model.trigger("backgrid:edit", model, column, this, this.currentEditor); - this.listenTo(model, "backgrid:error", this.renderError); - // Need to redundantly undelegate events for Firefox this.undelegateEvents(); this.empty(); @@ -1358,13 +1385,18 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ this.optionValues = optionValues; }, - _renderOptions: function (nvps, currentValue) { + setMultiple: function (multiple) { + this.multiple = multiple; + this.$el.prop("multiple", multiple); + }, + + _renderOptions: function (nvps, selectedValues) { var options = ''; for (var i = 0; i < nvps.length; i++) { options = options + this.template({ text: nvps[i][0], value: nvps[i][1], - selected: currentValue == nvps[i][1] + selected: selectedValues.indexOf(nvps[i][1]) > -1 }); } return options; @@ -1381,7 +1413,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ this.empty(); var optionValues = _.result(this, "optionValues"); - var currentValue = this.model.get(this.column.get("name")); + var selectedValues = this.formatter.fromRaw(this.model.get(this.column.get("name"))); if (!_.isArray(optionValues)) throw TypeError("optionValues must be an array"); @@ -1391,6 +1423,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ var optgroupName = null; var optgroup = null; var innerHTML = ''; + for (var i = 0; i < optionValues.length; i++) { var optionValue = optionValues[i]; @@ -1401,12 +1434,12 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ innerHTML += this.template({ text: optionText, value: optionValue, - selected: optionValue == currentValue + selected: selectedValues.indexOf(optionValue) > -1 }); } else if (_.isObject(optionValue)) { optgroupName = optionValue.name; - optgroup = this._renderOptions(optionValue.values, currentValue); + optgroup = this._renderOptions(optionValue.values, selectedValues); innerHTML = innerHTML + '' + optgroup + ''; } else { @@ -1448,6 +1481,9 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ command.moveUp() || command.moveDown() || e.type == "blur") { e.preventDefault(); e.stopPropagation(); + if (e.type == "blur" && this.$el.find("option").length === 1) { + model.set(column.get("name"), this.formatter.toRaw(this.$el.val())); + } model.trigger("backgrid:edited", model, column, new Command(e)); } } @@ -1456,11 +1492,10 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ /** SelectCell is also a different kind of cell in that upon going into edit mode - the cell renders a list of options for to pick from, as opposed to an input - box. + the cell renders a list of options to pick from, as opposed to an input box. SelectCell cannot be referenced by its string name when used in a column - definition because requires an `optionValues` class attribute to be + definition because it requires an `optionValues` class attribute to be defined. `optionValues` can either be a list of name-value pairs, to be rendered as options, or a list of object hashes which consist of a key *name* which is the option group name, and a key *values* which is a list of @@ -1468,11 +1503,12 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ In addition, `optionValues` can also be a parameter-less function that returns one of the above. If the options are static, it is recommended the - returned values to be memoized. _.memoize() is a good function to help with + returned values to be memoized. `_.memoize()` is a good function to help with that. - Lastly, since this class uses the default CellFormatter, during display mode, - the raw model value is compared with the `optionValues` values using + During display mode, the default formatter will normalize the raw model value + to an array of values whether the raw model value is a scalar or an + array. Each value is compared with the `optionValues` values using Ecmascript's implicit type conversion rules. When exiting edit mode, no type conversion is performed when saving into the model. This behavior is not always desirable when the value type is anything other than string. To @@ -1480,6 +1516,9 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ provide a custom formatter or provide the formatter to your column definition. + See: + [$.fn.val()](http://api.jquery.com/val/) + @class Backgrid.SelectCell @extends Backgrid.Cell */ @@ -1491,11 +1530,20 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ /** @property */ editor: SelectCellEditor, + /** @property */ + multiple: false, + + /** @property */ + formatter: new SelectFormatter(), + /** @property {Array.|Array.<{name: string, values: Array.}>} optionValues */ optionValues: undefined, + /** @property */ + delimiter: ', ', + /** Initializer. @@ -1508,10 +1556,10 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ initialize: function (options) { Cell.prototype.initialize.apply(this, arguments); Backgrid.requireOptions(this, ["optionValues"]); - this.optionValues = _.result(this, "optionValues"); this.listenTo(this.model, "backgrid:edit", function (model, column, cell, editor) { if (column.get("name") == this.column.get("name")) { editor.setOptionValues(this.optionValues); + editor.setMultiple(this.multiple); } }); }, @@ -1527,35 +1575,40 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ var optionValues = this.optionValues; var rawData = this.formatter.fromRaw(this.model.get(this.column.get("name"))); + var selectedText = []; + try { if (!_.isArray(optionValues) || _.isEmpty(optionValues)) throw new TypeError; - var doc = window.document; - for (var i = 0; i < optionValues.length; i++) { - var optionValue = optionValues[i]; - if (_.isArray(optionValue)) { - var optionText = optionValue[0]; - var optionValue = optionValue[1]; + for (var k = 0; k < rawData.length; k++) { + var rawDatum = rawData[k]; - if (optionValue == rawData) { - this.el.appendChild(doc.createTextNode(optionText)); - break; + for (var i = 0; i < optionValues.length; i++) { + var optionValue = optionValues[i]; + + if (_.isArray(optionValue)) { + var optionText = optionValue[0]; + var optionValue = optionValue[1]; + + if (optionValue == rawDatum) selectedText.push(optionText); } - } - else if (_.isObject(optionValue)) { - var optionGroupValues = optionValue.values; - for (var j = 0; j < optionGroupValues.length; j++) { - var optionGroupValue = optionGroupValues[j]; - if (optionGroupValue[1] == rawData) { - this.el.appendChild(doc.createTextNode(optionGroupValue[0])); - break; + else if (_.isObject(optionValue)) { + var optionGroupValues = optionValue.values; + + for (var j = 0; j < optionGroupValues.length; j++) { + var optionGroupValue = optionGroupValues[j]; + if (optionGroupValue[1] == rawDatum) { + selectedText.push(optionGroupValue[0]); + } } } - } - else { - throw new TypeError; + else { + throw new TypeError; + } } } + + this.el.appendChild(window.document.createTextNode(selectedText.join(this.delimiter))); } catch (ex) { if (ex instanceof TypeError) { diff --git a/lib/backgrid.min.css b/lib/backgrid.min.css index 131b6528..3989d662 100644 --- a/lib/backgrid.min.css +++ b/lib/backgrid.min.css @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -.backgrid-container{position:relative;display:block;width:100%;height:465px;padding:0;overflow:auto;border:0}.backgrid{width:100%;max-width:100%;background-color:transparent;border:1px solid #DDD;border-collapse:collapse;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.backgrid th,.backgrid td{height:20px;max-width:250px;padding:4px 5px;overflow:hidden;line-height:20px;text-align:left;text-overflow:ellipsis;white-space:nowrap;vertical-align:middle;border:1px solid #DDD}.backgrid th{font-weight:bold;cursor:pointer}.backgrid th a{white-space:nowrap}.backgrid thead th{vertical-align:bottom;background-color:#f9f9f9}.backgrid.backgrid-striped tbody tr:nth-child(odd) td,.backgrid.backgrid-striped tbody tr:nth-child(odd) th{background-color:#f9f9f9}.backgrid tbody tr.empty{font-style:italic;color:gray}.backgrid tbody tr.empty td{text-align:center}.backgrid td.editor,.backgrid tbody tr:nth-child(odd) td.editor{background-color:rgba(82,168,236,0.1);outline:1px solid rgba(82,168,236,0.8);outline-offset:-1px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition-duration:200ms;-moz-transition-duration:200ms;-o-transition-duration:200ms;transition-duration:200ms;-webkit-transition-property:width,outline,background-color;-moz-transition-property:width,outline,background-color;-o-transition-property:width,outline,background-color;transition-property:width,outline,background-color;-webkit-transition-timing-function:ease-in-out;-moz-transition-timing-function:ease-in-out;-o-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out}.backgrid td.editor input[type=text]{display:block;width:100%;height:100%;padding:0;margin:0;background-color:transparent;border:0;outline:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none}.backgrid td.editor.error,.backgrid tbody tr:nth-child(odd) td.editor.error{background-color:rgba(255,210,77,0.1);outline:1px solid #ffd24d}.backgrid td.editor :focus,.backgrid th.editor:focus{outline:0}.backgrid .sort-caret{display:inline-block;width:0;height:0;margin-left:.3em;border:0;content:""}.backgrid .ascending .sort-caret{vertical-align:baseline;border-top:0;border-right:4px solid transparent;border-bottom:4px solid #000;border-left:4px solid transparent}.backgrid .descending .sort-caret{vertical-align:super;border-top:4px solid #000;border-right:4px solid transparent;border-bottom:0;border-left:4px solid transparent}.backgrid .string-cell,.backgrid .uri-cell,.backgrid .email-cell,.backgrid .string-cell.editor input[type=text],.backgrid .uri-cell.editor input[type=text],.backgrid .email-cell.editor input[type=text]{text-align:left}.backgrid .date-cell,.backgrid .time-cell,.backgrid .datetime-cell,.backgrid .number-cell,.backgrid .integer-cell,.backgrid .date-cell.editor input[type=text],.backgrid .time-cell.editor input[type=text],.backgrid .datetime-cell.editor input[type=text],.backgrid .number-cell.editor input[type=text],.backgrid .integer-cell.editor input[type=text]{text-align:right}.backgrid .boolean-cell,.backgrid .boolean-cell.editor input[type=checkbox]{text-align:center}.backgrid .select-cell{text-align:center}.backgrid .select-cell.editor{padding:0}.backgrid .select-cell.editor select{display:block;width:100%;height:28px;padding:4px 5px;margin:0;line-height:28px;vertical-align:middle;background-color:white;border:0;outline:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.backgrid .select-cell.editor :focus{border:0;outline:0}.backgrid .select-cell.editor select::-moz-focus-inner,.backgrid .select-cell.editor optgroup::-moz-focus-inner,.backgrid .select-cell.editor option::-moz-focus-inner,.backgrid .select-cell.editor select::-o-focus-inner,.backgrid .select-cell.editor optgroup::-o-focus-inner,.backgrid .select-cell.editor option::-o-focus-inner{border:0} +.backgrid-container{position:relative;display:block;width:100%;height:465px;padding:0;overflow:auto;border:0}.backgrid{width:100%;max-width:100%;background-color:transparent;border:1px solid #DDD;border-collapse:collapse;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.backgrid th,.backgrid td{height:20px;max-width:250px;padding:4px 5px;overflow:hidden;line-height:20px;text-align:left;text-overflow:ellipsis;white-space:nowrap;vertical-align:middle;border:1px solid #DDD}.backgrid th{font-weight:bold;cursor:pointer}.backgrid th a{white-space:nowrap}.backgrid thead th{vertical-align:bottom;background-color:#f9f9f9}.backgrid.backgrid-striped tbody tr:nth-child(odd) td,.backgrid.backgrid-striped tbody tr:nth-child(odd) th{background-color:#f9f9f9}.backgrid tbody tr.empty{font-style:italic;color:gray}.backgrid tbody tr.empty td{text-align:center}.backgrid td.editor,.backgrid tbody tr:nth-child(odd) td.editor{background-color:rgba(82,168,236,0.1);outline:1px solid rgba(82,168,236,0.8);outline-offset:-1px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition-duration:200ms;-moz-transition-duration:200ms;-o-transition-duration:200ms;transition-duration:200ms;-webkit-transition-property:width,outline,background-color;-moz-transition-property:width,outline,background-color;-o-transition-property:width,outline,background-color;transition-property:width,outline,background-color;-webkit-transition-timing-function:ease-in-out;-moz-transition-timing-function:ease-in-out;-o-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out}.backgrid td.editor input[type=text]{display:block;width:100%;height:100%;padding:0;margin:0;background-color:transparent;border:0;outline:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none}.backgrid td.error,.backgrid tbody tr:nth-child(odd) td.error{background-color:rgba(255,210,77,0.1);outline:1px solid #ffd24d}.backgrid td.editor :focus,.backgrid th.editor:focus{outline:0}.backgrid .sort-caret{display:inline-block;width:0;height:0;margin-left:.3em;border:0;content:""}.backgrid .ascending .sort-caret{vertical-align:baseline;border-top:0;border-right:4px solid transparent;border-bottom:4px solid #000;border-left:4px solid transparent}.backgrid .descending .sort-caret{vertical-align:super;border-top:4px solid #000;border-right:4px solid transparent;border-bottom:0;border-left:4px solid transparent}.backgrid .string-cell,.backgrid .uri-cell,.backgrid .email-cell,.backgrid .string-cell.editor input[type=text],.backgrid .uri-cell.editor input[type=text],.backgrid .email-cell.editor input[type=text]{text-align:left}.backgrid .date-cell,.backgrid .time-cell,.backgrid .datetime-cell,.backgrid .number-cell,.backgrid .integer-cell,.backgrid .date-cell.editor input[type=text],.backgrid .time-cell.editor input[type=text],.backgrid .datetime-cell.editor input[type=text],.backgrid .number-cell.editor input[type=text],.backgrid .integer-cell.editor input[type=text]{text-align:right}.backgrid .boolean-cell,.backgrid .boolean-cell.editor input[type=checkbox]{text-align:center}.backgrid .select-cell{text-align:center}.backgrid .select-cell.editor{padding:0}.backgrid .select-cell.editor select{display:block;width:100%;height:28px;padding:4px 5px;margin:0;line-height:28px;vertical-align:middle;background-color:white;border:0;outline:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.backgrid .select-cell.editor :focus{border:0;outline:0}.backgrid .select-cell.editor select::-moz-focus-inner,.backgrid .select-cell.editor optgroup::-moz-focus-inner,.backgrid .select-cell.editor option::-moz-focus-inner,.backgrid .select-cell.editor select::-o-focus-inner,.backgrid .select-cell.editor optgroup::-o-focus-inner,.backgrid .select-cell.editor option::-o-focus-inner{border:0} diff --git a/lib/backgrid.min.js b/lib/backgrid.min.js index 7e0a7563..82928f53 100644 --- a/lib/backgrid.min.js +++ b/lib/backgrid.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,i,n){"use strict";function r(e){return String.fromCharCode(e.charCodeAt(0)-32)+e.slice(1)}function o(e,t,i){var n=t-(e+"").length;n=0>n?0:n;for(var r="",o=0;n>o;o++)r+=i;return r+e}var s=e,l=" \n \f\r   ᠎              \u2028\u2029";if(!String.prototype.trim||l.trim()){l="["+l+"]";var a=RegExp("^"+l+l+"*"),h=RegExp(l+l+"*$");String.prototype.trim=function(){if(void 0===this||null===this)throw new TypeError("can't convert "+this+" to object");return(this+"").replace(a,"").replace(h,"")}}var c=e.Backgrid={VERSION:"0.2.5",Extension:{},requireOptions:function(e,t){for(var n=0;t.length>n;n++){var r=t[n];if(i.isUndefined(e[r]))throw new TypeError("'"+r+"' is required")}},resolveNameToClass:function(e,t){if(i.isString(e)){var n=i.map(e.split("-"),function(e){return r(e)}).join("")+t,o=c[n]||c.Extension[n];if(i.isUndefined(o))throw new ReferenceError("Class '"+n+"' not found");return o}return e}};i.extend(c,n.Events);var d=c.Command=function(e){i.extend(this,{altKey:!!e.altKey,"char":e.char,charCode:e.charCode,ctrlKey:!!e.ctrlKey,key:e.key,keyCode:e.keyCode,locale:e.locale,location:e.location,metaKey:!!e.metaKey,repeat:!!e.repeat,shiftKey:!!e.shiftKey,which:e.which})};i.extend(d.prototype,{moveUp:function(){return 38==this.keyCode},moveDown:function(){return 40===this.keyCode},moveLeft:function(){return this.shiftKey&&9===this.keyCode},moveRight:function(){return!this.shiftKey&&9===this.keyCode},save:function(){return 13===this.keyCode},cancel:function(){return 27===this.keyCode},passThru:function(){return!(this.moveUp()||this.moveDown()||this.moveLeft()||this.moveRight()||this.save()||this.cancel())}});var u=["model","collection","el","id","attributes","className","tagName","events"],m=c.View=function(e){this.cid=i.uniqueId("view"),this.options=e=e||{},i.extend(this,i.pick(e,u)),this._ensureElement(e),this.initialize.apply(this,arguments),this.delegateEvents()},f=/^(\S+)\s*(.*)$/;i.extend(m.prototype,n.Events,{use$:!1,tagName:"div",$:function(e){return this.$el?this.$el.find(e):this.el.querySelectorAll(e)},initialize:function(){},render:function(){return this},empty:function(){if(this.$el)this.$el.remove();else for(var e=this.el;e.hasChildNodes();)e.removeChild(e.firstChild);return this},remove:function(){return this.empty(),this.stopListening(),this},setElement:function(e,t){t=i.extend({use$:n.$&&this.use$,delegate:!0},t||{});var r=t.delegate;return this.el&&this.undelegateEvents(),this.el=e,t.use$&&(this.$el=n.$(e)),r!==!1&&this.delegateEvents(),this},_processEvents:function(e,t){for(var n in e){var r=e[n];if(i.isFunction(r)||(r=this[e[n]]),r){r=i.bind(r,this);var o=n.match(f);t(o[1],o[2],r)}}},delegateEvents:function(e){if(!e&&!(e=i.result(this,"events")))return this;this.undelegateEvents();var t=this.el,n=this.$el,r=this.cid;return this._processEvents(e,function(e,i,o){var s=e+".delegateEvents"+r;if(""===i)n?n.on(s,o):t.addEventListener?t.addEventListener(e,o):t.attachEvent&&t.attachEvent("on"+e,o);else if(n)n.on(s,i,o);else for(var l=t.querySelectorAll(i),a=0,h=l.length;h>a;a++){var c=l[a];t.addEventListener?c.addEventListener(e,o):t.attachEvent&&c.attachEvent("on"+e,o)}}),this},undelegateEvents:function(){var e=i.result(this,"events");if(!e)return this;if(this.$el)this.$el.off(".delegateEvents"+this.cid);else{var t=this.el;this._processEvents(e,function(e,i,n){if(""===i)t.removeEventListener&&t.removeEventListener(e,n),t.detachEvent&&t.detachEvent("on"+e,n);else for(var r=t.querySelectorAll(i),o=0,s=r.length;s>o;o++){var l=r[o];t.removeEventListener?l.removeEventListener(e,n):t.detachEvent&&l.detachEvent("on"+e,n)}})}return this},_ensureElement:function(e){if(e=i.extend(e,{delegate:!1}),this.el)this.setElement(i.result(this,"el"),e);else{var t=this.el=s.document.createElement(this.tagName),n=i.extend({},i.result(this,"attributes"));this.id&&(n.id=i.result(this,"id")),this.className&&(n["class"]=i.result(this,"className"));for(var r in n)t.setAttribute(r,n[r]);this.setElement(t,e)}}}),m.extend=n.View.extend;var p=c.CellFormatter=function(){};i.extend(p.prototype,{fromRaw:function(e){return e},toRaw:function(e){return e}});var v=c.NumberFormatter=function(e){if(e=e?i.clone(e):{},i.extend(this,this.defaults,e),0>this.decimals||this.decimals>20)throw new RangeError("decimals must be between 0 and 20")};v.prototype=new p,i.extend(v.prototype,{defaults:{decimals:2,decimalSeparator:".",orderSeparator:","},HUMANIZED_NUM_RE:/(\d)(?=(?:\d{3})+$)/g,fromRaw:function(e){if(i.isNull(e)||i.isUndefined(e))return"";e=e.toFixed(~~this.decimals);var t=e.split("."),n=t[0],r=t[1]?(this.decimalSeparator||".")+t[1]:"";return n.replace(this.HUMANIZED_NUM_RE,"$1"+this.orderSeparator)+r},toRaw:function(e){for(var t="",n=e.trim().split(this.orderSeparator),r=0;n.length>r;r++)t+=n[r];var o=t.split(this.decimalSeparator);t="";for(var r=0;o.length>r;r++)t=t+o[r]+".";"."===t[t.length-1]&&(t=t.slice(0,t.length-1));var s=1*(1*t).toFixed(~~this.decimals);return i.isNumber(s)&&!i.isNaN(s)?s:void 0}});var g=c.DatetimeFormatter=function(e){if(e=e?i.clone(e):{},i.extend(this,this.defaults,e),!this.includeDate&&!this.includeTime)throw Error("Either includeDate or includeTime must be true")};g.prototype=new p,i.extend(g.prototype,{defaults:{includeDate:!0,includeTime:!0,includeMilli:!1},DATE_RE:/^([+\-]?\d{4})-(\d{2})-(\d{2})$/,TIME_RE:/^(\d{2}):(\d{2}):(\d{2})(\.(\d{3}))?$/,ISO_SPLITTER_RE:/T|Z| +/,_convert:function(e,t){e=e.trim();var n=e.split(this.ISO_SPLITTER_RE)||[],r=this.DATE_RE.test(n[0])?n[0]:"",s=r&&n[1]?n[1]:this.TIME_RE.test(n[0])?n[0]:"",l=this.DATE_RE.exec(r)||[],a=this.TIME_RE.exec(s)||[];if(t){if(this.includeDate&&i.isUndefined(l[0]))return;if(this.includeTime&&i.isUndefined(a[0]))return;if(!this.includeDate&&r)return;if(!this.includeTime&&s)return}var h=new Date(Date.UTC(1*l[1]||0,1*l[2]-1||0,1*l[3]||0,1*a[1]||null,1*a[2]||null,1*a[3]||null,1*a[5]||null)),c="";return this.includeDate&&(c=o(h.getUTCFullYear(),4,0)+"-"+o(h.getUTCMonth()+1,2,0)+"-"+o(h.getUTCDate(),2,0)),this.includeTime&&(c=c+(this.includeDate?"T":"")+o(h.getUTCHours(),2,0)+":"+o(h.getUTCMinutes(),2,0)+":"+o(h.getUTCSeconds(),2,0),this.includeMilli&&(c=c+"."+o(h.getUTCMilliseconds(),3,0))),this.includeDate&&this.includeTime&&(c+="Z"),c},fromRaw:function(e){return i.isNull(e)||i.isUndefined(e)?"":this._convert(e)},toRaw:function(e){return this._convert(e,!0)}});var y=c.StringFormatter=function(){};y.prototype=new p,i.extend(y.prototype,{fromRaw:function(e){return i.isUndefined(e)||i.isNull(e)?"":e+""}});var w=c.EmailFormatter=function(){};w.prototype=new p,i.extend(w.prototype,{toRaw:function(e){var t=e.trim().split("@");return 2===t.length&&i.all(t)?e:void 0}});var E=c.CellEditor=c.View.extend({initialize:function(e){c.requireOptions(e,["formatter","column","model"]),this.formatter=e.formatter,this.column=e.column,this.column instanceof D||(this.column=new D(this.column)),this.listenTo(this.model,"backgrid:editing",this.postRender)},postRender:function(e,t){return(null==t||t.get("name")==this.column.get("name"))&&this.el.focus(),this}}),C=c.InputCellEditor=E.extend({tagName:"input",attributes:{type:"text"},events:{blur:"saveOrCancel",keydown:"saveOrCancel"},initialize:function(e){E.prototype.initialize.apply(this,arguments),e.placeholder&&this.el.setAttribute("placeholder",e.placeholder)},render:function(){return this.el.value=this.formatter.fromRaw(this.model.get(this.column.get("name"))),this},saveOrCancel:function(e){var t=this.formatter,n=this.model,r=this.column,o=new d(e),s="blur"===e.type;if(o.moveUp()||o.moveDown()||o.moveLeft()||o.moveRight()||o.save()||s){e.preventDefault(),e.stopPropagation();var l=this.el.value,a=t.toRaw(l);i.isUndefined(a)?n.trigger("backgrid:error",n,r,l):(n.set(r.get("name"),a),n.trigger("backgrid:edited",n,r,o))}else o.cancel()&&(e.stopPropagation(),n.trigger("backgrid:edited",n,r,o))},postRender:function(e,t){if(null==t||t.get("name")==this.column.get("name")){var i,n=this.el;if(s.getComputedStyle?i=s.getComputedStyle(n).textAlign:n.currentStyle&&(i=n.currentStyle.textAlign),"right"===i){var r=n.value;n.focus(),n.val=null,n.val=r}else n.focus()}return this}}),b=c.Cell=c.View.extend({tagName:"td",formatter:new p,editor:C,events:{click:"enterEditMode"},initialize:function(e){c.requireOptions(e,["model","column"]),this.column=e.column,this.column instanceof D||(this.column=new D(this.column)),this.formatter=c.resolveNameToClass(this.column.get("formatter")||this.formatter,"Formatter"),this.editor=c.resolveNameToClass(this.editor,"CellEditor"),this.listenTo(this.model,"change:"+this.column.get("name"),function(){this.el.classList.contains("editor")||this.render()})},show:function(){return this.el.style.display="",this},hide:function(){return this.el.style.display="none",this},render:function(){return this.empty(),this.el.appendChild(s.document.createTextNode(this.formatter.fromRaw(this.model.get(this.column.get("name"))))),this.delegateEvents(),this},enterEditMode:function(){var e=this.model,t=this.column;t.get("editable")&&(this.currentEditor=new this.editor({column:this.column,model:this.model,formatter:this.formatter}),e.trigger("backgrid:edit",e,t,this,this.currentEditor),this.listenTo(e,"backgrid:error",this.renderError),this.undelegateEvents(),this.empty(),this.el.appendChild(this.currentEditor.el),this.currentEditor.render(),this.el.classList.add("editor"),e.trigger("backgrid:editing",e,t,this,this.currentEditor))},renderError:function(e,t){(null==t||t.get("name")==this.column.get("name"))&&this.el.classList.add("error")},exitEditMode:function(){this.el.classList.remove("error"),this.currentEditor.remove(),this.stopListening(this.currentEditor),delete this.currentEditor,this.el.classList.remove("editor"),this.render()},remove:function(){return this.currentEditor&&(this.currentEditor.remove.apply(this,arguments),delete this.currentEditor),c.View.prototype.remove.apply(this,arguments)}}),x=c.StringCell=b.extend({className:"string-cell",formatter:new y});c.UriCell=b.extend({className:"uri-cell",render:function(){this.empty();var e=this.formatter.fromRaw(this.model.get(this.column.get("name"))),t=s.document,i=t.createElement("a");return i.tabIndex=-1,i.href=e,i.title=e,i.target="_blank",i.appendChild(t.createTextNode(e)),this.el.appendChild(i),this.delegateEvents(),this}}),c.EmailCell=x.extend({className:"email-cell",formatter:new w,render:function(){this.empty();var e=this.formatter.fromRaw(this.model.get(this.column.get("name"))),t=s.document,i=t.createElement("a");return i.tabIndex=-1,i.href="mailto:"+e,i.title=e,i.appendChild(t.createTextNode(e)),this.el.appendChild(i),this.delegateEvents(),this}});var T=c.NumberCell=b.extend({className:"number-cell",decimals:v.prototype.defaults.decimals,decimalSeparator:v.prototype.defaults.decimalSeparator,orderSeparator:v.prototype.defaults.orderSeparator,formatter:v,initialize:function(){b.prototype.initialize.apply(this,arguments),this.formatter=new this.formatter({decimals:this.decimals,decimalSeparator:this.decimalSeparator,orderSeparator:this.orderSeparator})}});c.IntegerCell=T.extend({className:"integer-cell",decimals:0});var R=c.DatetimeCell=b.extend({className:"datetime-cell",includeDate:g.prototype.defaults.includeDate,includeTime:g.prototype.defaults.includeTime,includeMilli:g.prototype.defaults.includeMilli,formatter:g,initialize:function(){b.prototype.initialize.apply(this,arguments),this.formatter=new this.formatter({includeDate:this.includeDate,includeTime:this.includeTime,includeMilli:this.includeMilli});var e=this.includeDate?"YYYY-MM-DD":"";e+=this.includeDate&&this.includeTime?"T":"",e+=this.includeTime?"HH:mm:ss":"",e+=this.includeTime&&this.includeMilli?".SSS":"",this.editor=this.editor.extend({attributes:i.extend({},this.editor.prototype.attributes,this.editor.attributes,{placeholder:e})})}});c.DateCell=R.extend({className:"date-cell",includeTime:!1}),c.TimeCell=R.extend({className:"time-cell",includeDate:!1});var N=c.BooleanCellEditor=E.extend({tagName:"input",attributes:{tabIndex:-1,type:"checkbox"},events:{mousedown:function(){this.mouseDown=!0},blur:"enterOrExitEditMode",mouseup:function(){this.mouseDown=!1},change:"saveOrCancel",keydown:"saveOrCancel"},render:function(){var e=this.formatter.fromRaw(this.model.get(this.column.get("name")));return this.el.checked=e,this},enterOrExitEditMode:function(e){if(!this.mouseDown){var t=this.model;t.trigger("backgrid:edited",t,this.column,new d(e))}},saveOrCancel:function(e){var t=this.model,i=this.column,n=this.formatter,r=new d(e);if(r.passThru()&&"change"!=e.type)return!0;r.cancel()&&(e.stopPropagation(),t.trigger("backgrid:edited",t,i,r));var o=this.el;if(r.save()||r.moveLeft()||r.moveRight()||r.moveUp()||r.moveDown()){e.preventDefault(),e.stopPropagation();var s=n.toRaw(o.checked);t.set(i.get("name"),s),t.trigger("backgrid:edited",t,i,r)}else if("change"==e.type){var s=n.toRaw(o.checked);t.set(i.get("name"),s),o.focus()}}});c.BooleanCell=b.extend({className:"boolean-cell",editor:N,events:{click:"enterEditMode"},render:function(){this.empty();var e=s.document.createElement("input");return e.tabIndex=-1,e.type="checkbox",e.checked=this.formatter.fromRaw(this.model.get(this.column.get("name"))),this.el.appendChild(e),this.delegateEvents(),this}});var k=c.SelectCellEditor=E.extend({tagName:"select",events:{change:"save",blur:"close",keydown:"close"},template:i.template(''),setOptionValues:function(e){this.optionValues=e},_renderOptions:function(e,t){for(var i="",n=0;e.length>n;n++)i+=this.template({text:e[n][0],value:e[n][1],selected:t==e[n][1]});return i},render:function(){this.empty();var e=i.result(this,"optionValues"),t=this.model.get(this.column.get("name"));if(!i.isArray(e))throw TypeError("optionValues must be an array");for(var n=null,r=null,n=null,o=null,s=null,l="",a=0;e.length>a;a++){var n=e[a];if(i.isArray(n))r=n[0],n=n[1],l+=this.template({text:r,value:n,selected:n==t});else{if(!i.isObject(n))throw TypeError("optionValues elements must be a name-value pair or an object hash of { name: 'optgroup label', value: [option name-value pairs] }");o=n.name,s=this._renderOptions(n.values,t),l=l+''+s+""}}return this.el.innerHTML=l,this.delegateEvents(),this},save:function(e){var t=this.model,i=this.column;t.set(i.get("name"),this.formatter.toRaw(this.el.value)),t.trigger("backgrid:edited",t,i,new d(e))},close:function(e){var t=this.model,i=this.column,n=new d(e);n.cancel()?(e.stopPropagation(),t.trigger("backgrid:edited",t,i,new d(e))):(n.save()||n.moveLeft()||n.moveRight()||n.moveUp()||n.moveDown()||"blur"==e.type)&&(e.preventDefault(),e.stopPropagation(),t.trigger("backgrid:edited",t,i,new d(e)))}});c.SelectCell=b.extend({className:"select-cell",editor:k,optionValues:void 0,initialize:function(){b.prototype.initialize.apply(this,arguments),c.requireOptions(this,["optionValues"]),this.optionValues=i.result(this,"optionValues"),this.listenTo(this.model,"backgrid:edit",function(e,t,i,n){t.get("name")==this.column.get("name")&&n.setOptionValues(this.optionValues)})},render:function(){this.empty();var e=this.optionValues,t=this.formatter.fromRaw(this.model.get(this.column.get("name")));try{if(!i.isArray(e)||i.isEmpty(e))throw new TypeError;for(var n=s.document,r=0;e.length>r;r++){var o=e[r];if(i.isArray(o)){var l=o[0],o=o[1];if(o==t){this.el.appendChild(n.createTextNode(l));break}}else{if(!i.isObject(o))throw new TypeError;for(var a=o.values,h=0;a.length>h;h++){var c=a[h];if(c[1]==t){this.el.appendChild(n.createTextNode(c[0]));break}}}}}catch(d){if(d instanceof TypeError)throw TypeError("'optionValues' must be of type {Array.|Array.<{name: string, values: Array.}>}");throw d}return this.delegateEvents(),this}});var D=c.Column=n.Model.extend({defaults:{name:void 0,label:void 0,sortable:!0,editable:!0,renderable:!0,formatter:void 0,cell:void 0,headerCell:void 0},initialize:function(e){c.requireOptions(e,["cell","name"]),this.has("label")||this.set({label:this.get("name")},{silent:!0});var t=c.resolveNameToClass(this.get("headerCell"),"HeaderCell"),i=c.resolveNameToClass(this.get("cell"),"Cell");this.set({cell:i,headerCell:t},{silent:!0})}}),S=c.Columns=n.Collection.extend({model:D}),_=c.Row=c.View.extend({tagName:"tr",requiredOptions:["columns","model"],initialize:function(e){c.requireOptions(e,this.requiredOptions);var t=this.columns=e.columns;t instanceof n.Collection||(t=this.columns=new S(t));for(var i=this.cells=[],r=0;t.length>r;r++)i.push(this.makeCell(t.at(r),e));this.listenTo(t,"change:renderable",function(e,t){for(var n=0;i.length>n;n++){var r=i[n];r.column.get("name")==e.get("name")&&(t?r.show():r.hide())}}),this.listenTo(t,"add",function(t,n){var r=n.indexOf(t),o=this.makeCell(t,e);i.splice(r,0,o),o.column.get("renderable")||o.hide();var s=this.el,l=s.childNodes();0===r?s.insertBefore(o.render().el,s.firstChild):r===n.length-1?s.appendChild(o.render().el):s.insertBefore(o.render().el,l[r])}),this.listenTo(t,"remove",function(e,t,n){i[n.index].remove(),i.splice(n.index,1)})},makeCell:function(e){return new(e.get("cell"))({column:e,model:this.model})},render:function(){this.empty();for(var e=document.createDocumentFragment(),t=0;this.cells.length>t;t++){var i=this.cells[t];e.appendChild(i.render().el),i.column.get("renderable")||i.hide()}return this.el.appendChild(e),this.delegateEvents(),this},remove:function(){for(var e=0;this.cells.length>e;e++){var t=this.cells[e];t.remove.apply(t,arguments)}return c.View.prototype.remove.apply(this,arguments)}}),O=c.EmptyRow=c.View.extend({tagName:"tr",emptyText:null,initialize:function(e){c.requireOptions(e,["emptyText","columns"]),this.emptyText=e.emptyText,this.columns=e.columns},render:function(){this.empty();var e=document.createElement("td");return e.setAttribute("colspan",this.columns.length),e.textContent=this.emptyText,this.el.setAttribute("class","empty"),this.el.appendChild(e),this}}),M=c.HeaderCell=c.View.extend({tagName:"th",events:{"click a":"onClick"},_direction:null,initialize:function(e){c.requireOptions(e,["column","collection"]),this.column=e.column,this.column instanceof D||(this.column=new D(this.column)),this.listenTo(this.collection,"backgrid:sort",this._resetCellDirection)},direction:function(e){return arguments.length&&(this._direction&&this.el.classList.remove(this._direction),e&&this.el.classList.add(e),this._direction=e),this._direction},_resetCellDirection:function(e,t,i,n){n==this.collection&&(e!==this.column.get("name")?this.direction(null):this.direction(t))},onClick:function(e){e.preventDefault();var t=this.column.get("name");this.column.get("sortable")&&("ascending"===this.direction()?this.sort(t,"descending",function(e,i){var n=e.get(t),r=i.get(t);return n===r?0:n>r?-1:1}):"descending"===this.direction()?this.sort(t,null):this.sort(t,"ascending",function(e,i){var n=e.get(t),r=i.get(t);return n===r?0:r>n?-1:1}))},sort:function(e,t,i){i=i||this._cidComparator;var r=this.collection;if(n.PageableCollection&&r instanceof n.PageableCollection){var o;o="ascending"===t?-1:"descending"===t?1:null,r.setSorting(o?e:null,o),"client"==r.mode?(r.fullCollection.comparator||(r.fullCollection.comparator=i),r.fullCollection.sort()):r.fetch({reset:!0})}else r.comparator=i,r.sort();this.collection.trigger("backgrid:sort",e,t,i,this.collection)},_cidComparator:function(e,t){var n=e.cid,r=t.cid;if(!i.isUndefined(n)&&!i.isUndefined(r)){if(n=1*n.slice(1),r=1*r.slice(1),r>n)return-1;if(n>r)return 1}return 0},render:function(){this.empty();var e=s.document,t=e.createElement("a");t.appendChild(e.createTextNode(this.column.get("label")));var i=e.createElement("b");return i.className="sort-caret",t.appendChild(i),this.el.appendChild(t),this.delegateEvents(),this}});c.HeaderRow=c.Row.extend({requiredOptions:["columns","collection"],initialize:function(){c.Row.prototype.initialize.apply(this,arguments)},makeCell:function(e,t){var i=e.get("headerCell")||t.headerCell||M;return i=new i({column:e,collection:this.collection})}});var U=c.Header=c.View.extend({tagName:"thead",initialize:function(e){c.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new S(this.columns)),this.row=new c.HeaderRow({columns:this.columns,collection:this.collection})},render:function(){return this.el.appendChild(this.row.render().el),this.delegateEvents(),this},remove:function(){return this.row.remove.apply(this.row,arguments),c.View.prototype.remove.apply(this,arguments)}}),V=c.Body=c.View.extend({tagName:"tbody",initialize:function(e){c.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new S(this.columns)),this.row=e.row||_,this.rows=this.collection.map(function(e){var t=new this.row({columns:this.columns,model:e});return t},this),this.emptyText=e.emptyText,this._unshiftEmptyRowMayBe();var t=this.collection;this.listenTo(t,"add",this.insertRow),this.listenTo(t,"remove",this.removeRow),this.listenTo(t,"sort",this.refresh),this.listenTo(t,"reset",this.refresh),this.listenTo(t,"backgrid:edited",this.moveToNextCell)},_unshiftEmptyRowMayBe:function(){0===this.rows.length&&null!=this.emptyText&&this.rows.unshift(new O({emptyText:this.emptyText,columns:this.columns}))},insertRow:function(e,t,r){if(this.rows[0]instanceof O&&this.rows.pop().remove(),!(t instanceof n.Collection||r))return this.collection.add(e,r=t),void 0;r=i.extend({render:!0},r||{});var o=new this.row({columns:this.columns,model:e}),s=t.indexOf(e);this.rows.splice(s,0,o);var l=this.el,a=l.childNodes(),h=o.render().el;r.render&&(s>=a.length?l.appendChild(h):l.insertBefore(h,a[s]))},removeRow:function(e,t,n){return n?((i.isUndefined(n.render)||n.render)&&this.rows[n.index].remove(),this.rows.splice(n.index,1),this._unshiftEmptyRowMayBe(),void 0):(this.collection.remove(e,n=t),this._unshiftEmptyRowMayBe(),void 0)},refresh:function(){for(var e=0;this.rows.length>e;e++)this.rows[e].remove();return this.rows=this.collection.map(function(e){var t=new this.row({columns:this.columns,model:e});return t},this),this._unshiftEmptyRowMayBe(),this.render(),this.collection.trigger("backgrid:refresh",this),this},render:function(){this.empty();for(var e=document.createDocumentFragment(),t=0;this.rows.length>t;t++){var i=this.rows[t];e.appendChild(i.render().el)}return this.el.appendChild(e),this.delegateEvents(),this},remove:function(){for(var e=0;this.rows.length>e;e++){var t=this.rows[e];t.remove.apply(t,arguments)}return c.View.prototype.remove.apply(this,arguments)},moveToNextCell:function(e,t,i){var n=this.collection.indexOf(e),r=this.columns.indexOf(t);if(i.moveUp()||i.moveDown()||i.moveLeft()||i.moveRight()||i.save()){var o=this.columns.length,s=o*this.collection.length;if(i.moveUp()||i.moveDown()){var l=this.rows[n+(i.moveUp()?-1:1)];l&&l.cells[r].enterEditMode()}else if(i.moveLeft()||i.moveRight())for(var a=i.moveRight(),h=n*o+r+(a?1:-1);h>=0&&s>h;a?h++:h--){var c=~~(h/o),d=h-c*o,u=this.rows[c].cells[d];if(u.column.get("renderable")&&u.column.get("editable")){u.enterEditMode();break}}}this.rows[n].cells[r].exitEditMode()}});c.Footer=c.View.extend({tagName:"tfoot",initialize:function(e){c.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new c.Columns(this.columns))}}),c.Grid=c.View.extend({tagName:"table",className:"backgrid",header:U,body:V,footer:null,initialize:function(e){c.requireOptions(e,["columns","collection"]),e.columns instanceof n.Collection||(e.columns=new S(e.columns)),this.columns=e.columns;var t=i.omit(e,["el","id","attributes","className","tagName","events"]);this.header=e.header||this.header,this.header=new this.header(t),this.body=e.body||this.body,this.body=new this.body(t),this.footer=e.footer||this.footer,this.footer&&(this.footer=new this.footer(t)),this.listenTo(this.columns,"reset",function(){this.header=new(this.header.remove().constructor)(t),this.body=new(this.body.remove().constructor)(t),this.footer&&(this.footer=new(this.footer.remove().constructor)(t)),this.render()})},insertRow:function(e,t,i){return this.body.insertRow(e,t,i)},removeRow:function(e,t,i){return this.body.removeRow(e,t,i)},insertColumn:function(e,t){return t=t||{render:!0},this.columns.add(e,t),this},removeColumn:function(e,t){return this.columns.remove(e,t),this},render:function(){return this.empty(),this.el.appendChild(this.header.render().el),this.footer&&this.el.appendChild(this.footer.render().el),this.el.appendChild(this.body.render().el),this.delegateEvents(),this.trigger("backgrid:rendered",this),this},remove:function(){return this.header.remove.apply(this.header,arguments),this.body.remove.apply(this.body,arguments),this.footer&&this.footer.remove.apply(this.footer,arguments),c.View.prototype.remove.apply(this,arguments)}})})(this,jQuery,_,Backbone); \ No newline at end of file +(function(e,t,i,n){"use strict";function r(e){return String.fromCharCode(e.charCodeAt(0)-32)+e.slice(1)}function o(e,t,i){var n=t-(e+"").length;n=0>n?0:n;for(var r="",o=0;n>o;o++)r+=i;return r+e}var s=e,l=" \n \f\r   ᠎              \u2028\u2029";if(!String.prototype.trim||l.trim()){l="["+l+"]";var a=new RegExp("^"+l+l+"*"),h=new RegExp(l+l+"*$");String.prototype.trim=function(){if(void 0===this||null===this)throw new TypeError("can't convert "+this+" to object");return String(this).replace(a,"").replace(h,"")}}var c=e.Backgrid={VERSION:"0.2.6",Extension:{},requireOptions:function(e,t){for(var n=0;na;a++){var c=l[a];t.addEventListener?c.addEventListener(e,o):t.attachEvent&&c.attachEvent("on"+e,o)}}),this},undelegateEvents:function(){var e=i.result(this,"events");if(!e)return this;if(this.$el)this.$el.off(".delegateEvents"+this.cid);else{var t=this.el;this._processEvents(e,function(e,i,n){if(""===i)t.removeEventListener&&t.removeEventListener(e,n),t.detachEvent&&t.detachEvent("on"+e,n);else for(var r=t.querySelectorAll(i),o=0,s=r.length;s>o;o++){var l=r[o];t.removeEventListener?l.removeEventListener(e,n):t.detachEvent&&l.detachEvent("on"+e,n)}})}return this},_ensureElement:function(e){if(e=i.extend(e,{delegate:!1}),this.el)this.setElement(i.result(this,"el"),e);else{var t=this.el=s.document.createElement(this.tagName),n=i.extend({},i.result(this,"attributes"));this.id&&(n.id=i.result(this,"id")),this.className&&(n["class"]=i.result(this,"className"));for(var r in n)t.setAttribute(r,n[r]);this.setElement(t,e)}}}),m.extend=n.View.extend;var f=c.CellFormatter=function(){};i.extend(f.prototype,{fromRaw:function(e){return e},toRaw:function(e){return e}});var v=c.NumberFormatter=function(e){if(e=e?i.clone(e):{},i.extend(this,this.defaults,e),this.decimals<0||this.decimals>20)throw new RangeError("decimals must be between 0 and 20")};v.prototype=new f,i.extend(v.prototype,{defaults:{decimals:2,decimalSeparator:".",orderSeparator:","},HUMANIZED_NUM_RE:/(\d)(?=(?:\d{3})+$)/g,fromRaw:function(e){if(i.isNull(e)||i.isUndefined(e))return"";e=e.toFixed(~~this.decimals);var t=e.split("."),n=t[0],r=t[1]?(this.decimalSeparator||".")+t[1]:"";return n.replace(this.HUMANIZED_NUM_RE,"$1"+this.orderSeparator)+r},toRaw:function(e){for(var t="",n=e.trim().split(this.orderSeparator),r=0;r><%- text %>'),setOptionValues:function(e){this.optionValues=e},setMultiple:function(e){this.multiple=e,this.$el.prop("multiple",e)},_renderOptions:function(e,t){for(var i="",n=0;n-1});return i},render:function(){this.empty();var e=i.result(this,"optionValues"),t=this.formatter.fromRaw(this.model.get(this.column.get("name")));if(!i.isArray(e))throw TypeError("optionValues must be an array");for(var n=null,r=null,n=null,o=null,s=null,l="",a=0;a-1});else{if(!i.isObject(n))throw TypeError("optionValues elements must be a name-value pair or an object hash of { name: 'optgroup label', value: [option name-value pairs] }");o=n.name,s=this._renderOptions(n.values,t),l=l+''+s+""}}return this.el.innerHTML=l,this.delegateEvents(),this},save:function(e){var t=this.model,i=this.column;t.set(i.get("name"),this.formatter.toRaw(this.el.value)),t.trigger("backgrid:edited",t,i,new d(e))},close:function(e){var t=this.model,i=this.column,n=new d(e);n.cancel()?(e.stopPropagation(),t.trigger("backgrid:edited",t,i,new d(e))):(n.save()||n.moveLeft()||n.moveRight()||n.moveUp()||n.moveDown()||e.type=="blur")&&(e.preventDefault(),e.stopPropagation(),e.type=="blur"&&this.$el.find("option").length===1&&t.set(i.get("name"),this.formatter.toRaw(this.$el.val())),t.trigger("backgrid:edited",t,i,new d(e)))}});c.SelectCell=x.extend({className:"select-cell",editor:D,multiple:!1,formatter:new E,optionValues:void 0,delimiter:", ",initialize:function(){x.prototype.initialize.apply(this,arguments),c.requireOptions(this,["optionValues"]),this.listenTo(this.model,"backgrid:edit",function(e,t,i,n){t.get("name")==this.column.get("name")&&(n.setOptionValues(this.optionValues),n.setMultiple(this.multiple))})},render:function(){this.empty();var e=this.optionValues,t=this.formatter.fromRaw(this.model.get(this.column.get("name"))),n=[];try{if(!i.isArray(e)||i.isEmpty(e))throw new TypeError;for(var r=0;r|Array.<{name: string, values: Array.}>}");throw m}return this.delegateEvents(),this}});var S=c.Column=n.Model.extend({defaults:{name:void 0,label:void 0,sortable:!0,editable:!0,renderable:!0,formatter:void 0,cell:void 0,headerCell:void 0},initialize:function(e){c.requireOptions(e,["cell","name"]),this.has("label")||this.set({label:this.get("name")},{silent:!0});var t=c.resolveNameToClass(this.get("headerCell"),"HeaderCell"),i=c.resolveNameToClass(this.get("cell"),"Cell");this.set({cell:i,headerCell:t},{silent:!0})}}),_=c.Columns=n.Collection.extend({model:S}),M=c.Row=c.View.extend({tagName:"tr",requiredOptions:["columns","model"],initialize:function(e){c.requireOptions(e,this.requiredOptions);var t=this.columns=e.columns;t instanceof n.Collection||(t=this.columns=new _(t));for(var i=this.cells=[],r=0;rr?-1:1}):this.direction()==="descending"?this.sort(t,null):this.sort(t,"ascending",function(e,i){var n=e.get(t),r=i.get(t);return n===r?0:r>n?-1:1}))},sort:function(e,t,i){i=i||this._cidComparator;var r=this.collection;if(n.PageableCollection&&r instanceof n.PageableCollection){var o;o="ascending"===t?-1:"descending"===t?1:null,r.setSorting(o?e:null,o),r.mode=="client"?(r.fullCollection.comparator||(r.fullCollection.comparator=i),r.fullCollection.sort()):r.fetch({reset:!0})}else r.comparator=i,r.sort();this.collection.trigger("backgrid:sort",e,t,i,this.collection)},_cidComparator:function(e,t){var n=e.cid,r=t.cid;if(!i.isUndefined(n)&&!i.isUndefined(r)){if(n=n.slice(1)*1,r=r.slice(1)*1,r>n)return-1;if(n>r)return 1}return 0},render:function(){this.empty();var e=s.document,t=e.createElement("a");t.appendChild(e.createTextNode(this.column.get("label")));var i=e.createElement("b");return i.className="sort-caret",t.appendChild(i),this.el.appendChild(t),this.delegateEvents(),this}});c.HeaderRow=c.Row.extend({requiredOptions:["columns","collection"],initialize:function(){c.Row.prototype.initialize.apply(this,arguments)},makeCell:function(e,t){var i=e.get("headerCell")||t.headerCell||U;return i=new i({column:e,collection:this.collection})}});var V=c.Header=c.View.extend({tagName:"thead",initialize:function(e){c.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new _(this.columns)),this.row=new c.HeaderRow({columns:this.columns,collection:this.collection})},render:function(){return this.el.appendChild(this.row.render().el),this.delegateEvents(),this},remove:function(){return this.row.remove.apply(this.row,arguments),c.View.prototype.remove.apply(this,arguments)}}),L=c.Body=c.View.extend({tagName:"tbody",initialize:function(e){c.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new _(this.columns)),this.row=e.row||M,this.rows=this.collection.map(function(e){var t=new this.row({columns:this.columns,model:e});return t},this),this.emptyText=e.emptyText,this._unshiftEmptyRowMayBe();var t=this.collection;this.listenTo(t,"add",this.insertRow),this.listenTo(t,"remove",this.removeRow),this.listenTo(t,"sort",this.refresh),this.listenTo(t,"reset",this.refresh),this.listenTo(t,"backgrid:edited",this.moveToNextCell)},_unshiftEmptyRowMayBe:function(){this.rows.length===0&&this.emptyText!=null&&this.rows.unshift(new O({emptyText:this.emptyText,columns:this.columns}))},insertRow:function(e,t,r){if(this.rows[0]instanceof O&&this.rows.pop().remove(),!(t instanceof n.Collection||r))return this.collection.add(e,r=t),void 0;r=i.extend({render:!0},r||{});var o=new this.row({columns:this.columns,model:e}),s=t.indexOf(e);this.rows.splice(s,0,o);var l=this.el,a=l.childNodes(),h=o.render().el;r.render&&(s>=a.length?l.appendChild(h):l.insertBefore(h,a[s]))},removeRow:function(e,t,n){return n?((i.isUndefined(n.render)||n.render)&&this.rows[n.index].remove(),this.rows.splice(n.index,1),this._unshiftEmptyRowMayBe(),void 0):(this.collection.remove(e,n=t),this._unshiftEmptyRowMayBe(),void 0)},refresh:function(){for(var e=0;e=0&&s>h;a?h++:h--){var c=~~(h/o),d=h-c*o,u=this.rows[c].cells[d];if(u.column.get("renderable")&&u.column.get("editable")){u.enterEditMode();break}}}this.rows[n].cells[r].exitEditMode()}});c.Footer=c.View.extend({tagName:"tfoot",initialize:function(e){c.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof n.Collection||(this.columns=new c.Columns(this.columns))}}),c.Grid=c.View.extend({tagName:"table",className:"backgrid",header:V,body:L,footer:null,initialize:function(e){c.requireOptions(e,["columns","collection"]),e.columns instanceof n.Collection||(e.columns=new _(e.columns)),this.columns=e.columns;var t=i.omit(e,["el","id","attributes","className","tagName","events"]);this.header=e.header||this.header,this.header=new this.header(t),this.body=e.body||this.body,this.body=new this.body(t),this.footer=e.footer||this.footer,this.footer&&(this.footer=new this.footer(t)),this.listenTo(this.columns,"reset",function(){this.header=new(this.header.remove().constructor)(t),this.body=new(this.body.remove().constructor)(t),this.footer&&(this.footer=new(this.footer.remove().constructor)(t)),this.render()})},insertRow:function(e,t,i){return this.body.insertRow(e,t,i)},removeRow:function(e,t,i){return this.body.removeRow(e,t,i)},insertColumn:function(e,t){return t=t||{render:!0},this.columns.add(e,t),this},removeColumn:function(e,t){return this.columns.remove(e,t),this},render:function(){return this.empty(),this.el.appendChild(this.header.render().el),this.footer&&this.el.appendChild(this.footer.render().el),this.el.appendChild(this.body.render().el),this.delegateEvents(),this.trigger("backgrid:rendered",this),this},remove:function(){return this.header.remove.apply(this.header,arguments),this.body.remove.apply(this.body,arguments),this.footer&&this.footer.remove.apply(this.footer,arguments),c.View.prototype.remove.apply(this,arguments)}})})(this,jQuery,_,Backbone); \ No newline at end of file diff --git a/lib/extensions/filter/backgrid-filter.js b/lib/extensions/filter/backgrid-filter.js index ce935f85..2d2f3968 100644 --- a/lib/extensions/filter/backgrid-filter.js +++ b/lib/extensions/filter/backgrid-filter.js @@ -50,6 +50,15 @@ Backgrid.View.prototype.initialize.apply(this, arguments); this.name = options.name || this.name; this.placeholder = options.placeholder || this.placeholder; + + var collection = this.collection, self = this; + if (Backbone.PageableCollection && + collection instanceof Backbone.PageableCollection && + collection.mode == "server") { + collection.queryParams[this.name] = function () { + return self.searchBox().value; + }; + } }, searchBox: function () { @@ -65,7 +74,7 @@ if (e) e.preventDefault(); var searchBox = this.searchBox(); var data = {}; - data[searchBox.name] = searchBox.value; + data[this.name] = searchBox.value; this.collection.fetch({data: data}); }, diff --git a/lib/extensions/filter/backgrid-filter.min.js b/lib/extensions/filter/backgrid-filter.min.js index 0b808c81..08f3697b 100644 --- a/lib/extensions/filter/backgrid-filter.min.js +++ b/lib/extensions/filter/backgrid-filter.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,i,n){"use strict";var s=i.Extension.ServerSideFilter=i.View.extend({tagName:"form",className:"backgrid-filter form-search",template:e.template('
    placeholder="<%- placeholder %>" <% } %> name="<%- name %>" />×
    '),events:{"click .close":"clear",submit:"search"},name:"q",placeholder:null,initialize:function(e){i.requireOptions(e,["collection"]),i.View.prototype.initialize.apply(this,arguments),this.name=e.name||this.name,this.placeholder=e.placeholder||this.placeholder},searchBox:function(){return this.el.querySelector("input[type=text]")},search:function(e){e&&e.preventDefault();var t=this.searchBox(),i={};i[t.name]=t.value,this.collection.fetch({data:i})},clear:function(e){e&&e.preventDefault(),this.searchBox().value=null,this.collection.fetch()},render:function(){return this.empty().el.innerHTML=this.template({name:this.name,placeholder:this.placeholder,value:this.value}),this.delegateEvents(),this}}),a=i.Extension.ClientSideFilter=s.extend({events:{"click .close":function(e){e.preventDefault(),this.clear()},"change input[type=text]":"search","keyup input[type=text]":"search",submit:function(e){e.preventDefault(),this.search()}},fields:null,wait:149,initialize:function(t){s.prototype.initialize.apply(this,arguments),this.fields=t.fields||this.fields,this.wait=t.wait||this.wait,this._debounceMethods(["search","clear"]);var i=this.collection,n=this.shadowCollection=i.clone();n.url=i.url,n.sync=i.sync,n.parse=i.parse,this.listenTo(i,"add",function(e,t,i){n.add(e,i)}),this.listenTo(i,"remove",function(e,t,i){n.remove(e,i)}),this.listenTo(i,"sort reset",function(t,i){i=e.extend({reindex:!0},i||{}),i.reindex&&n.reset(t.models)})},_debounceMethods:function(t){e.isString(t)&&(t=[t]),this.undelegateEvents();for(var i=0,n=t.length;n>i;i++){var s=t[i],a=this[s];this[s]=e.debounce(a,this.wait)}this.delegateEvents()},makeMatcher:function(e){var t=RegExp(e.trim().split(/\W/).join("|"),"i");return function(e){for(var i=this.fields||e.keys(),n=0,s=i.length;s>n;n++)if(t.test(e.get(i[n])+""))return!0;return!1}},search:function(){var t=e.bind(this.makeMatcher(this.searchBox().value),this);this.collection.reset(this.shadowCollection.filter(t),{reindex:!1})},clear:function(){this.searchBox().value=null,this.collection.reset(this.shadowCollection.models,{reindex:!1})}});i.Extension.LunrFilter=a.extend({ref:"id",fields:null,initialize:function(e){a.prototype.initialize.apply(this,arguments),this.ref=e.ref||this.ref;var t=this.collection;this.listenTo(t,"add",this.addToIndex),this.listenTo(t,"remove",this.removeFromIndex),this.listenTo(t,"reset",this.resetIndex),this.listenTo(t,"change",this.updateIndex),this.resetIndex(t)},resetIndex:function(t,i){if(i=e.extend({reindex:!0},i||{}),i.reindex){var s=this;this.index=n(function(){e.each(s.fields,function(e,t){this.field(t,e),this.ref(s.ref)},this)}),t.each(function(e){this.addToIndex(e)},this)}},addToIndex:function(e){var t=this.index,i=e.toJSON();t.documentStore.has(i[this.ref])?t.update(i):t.add(i)},removeFromIndex:function(e){var t=this.index,i=e.toJSON();t.documentStore.has(i[this.ref])&&t.remove(i)},updateIndex:function(t){var i=t.changedAttributes();i&&!e.isEmpty(e.intersection(e.keys(this.fields),e.keys(i)))&&this.index.update(t.toJSON())},search:function(){for(var e=this.index.search(this.searchBox().value),t=[],i=0;e.length>i;i++){var n=e[i];t.push(this.shadowCollection.get(n.ref))}this.collection.reset(t,{reindex:!1})}})})(_,Backbone,Backgrid,lunr); \ No newline at end of file +(function(e,t,i,n){"use strict";var s=i.Extension.ServerSideFilter=i.View.extend({tagName:"form",className:"backgrid-filter form-search",template:e.template('
    placeholder="<%- placeholder %>" <% } %> name="<%- name %>" />×
    '),events:{"click .close":"clear",submit:"search"},name:"q",placeholder:null,initialize:function(e){i.requireOptions(e,["collection"]),i.View.prototype.initialize.apply(this,arguments),this.name=e.name||this.name,this.placeholder=e.placeholder||this.placeholder;var n=this.collection,s=this;t.PageableCollection&&n instanceof t.PageableCollection&&n.mode=="server"&&(n.queryParams[this.name]=function(){return s.searchBox().value})},searchBox:function(){return this.el.querySelector("input[type=text]")},search:function(e){e&&e.preventDefault();var t=this.searchBox(),i={};i[this.name]=t.value,this.collection.fetch({data:i})},clear:function(e){e&&e.preventDefault(),this.searchBox().value=null,this.collection.fetch()},render:function(){return this.empty().el.innerHTML=this.template({name:this.name,placeholder:this.placeholder,value:this.value}),this.delegateEvents(),this}}),a=i.Extension.ClientSideFilter=s.extend({events:{"click .close":function(e){e.preventDefault(),this.clear()},"change input[type=text]":"search","keyup input[type=text]":"search",submit:function(e){e.preventDefault(),this.search()}},fields:null,wait:149,initialize:function(t){s.prototype.initialize.apply(this,arguments),this.fields=t.fields||this.fields,this.wait=t.wait||this.wait,this._debounceMethods(["search","clear"]);var i=this.collection,n=this.shadowCollection=i.clone();n.url=i.url,n.sync=i.sync,n.parse=i.parse,this.listenTo(i,"add",function(e,t,i){n.add(e,i)}),this.listenTo(i,"remove",function(e,t,i){n.remove(e,i)}),this.listenTo(i,"sort reset",function(t,i){i=e.extend({reindex:!0},i||{}),i.reindex&&n.reset(t.models)})},_debounceMethods:function(t){e.isString(t)&&(t=[t]),this.undelegateEvents();for(var i=0,n=t.length;n>i;i++){var s=t[i],a=this[s];this[s]=e.debounce(a,this.wait)}this.delegateEvents()},makeMatcher:function(e){var t=new RegExp(e.trim().split(/\W/).join("|"),"i");return function(e){for(var i=this.fields||e.keys(),n=0,s=i.length;s>n;n++)if(t.test(e.get(i[n])+""))return!0;return!1}},search:function(){var t=e.bind(this.makeMatcher(this.searchBox().value),this);this.collection.reset(this.shadowCollection.filter(t),{reindex:!1})},clear:function(){this.searchBox().value=null,this.collection.reset(this.shadowCollection.models,{reindex:!1})}});i.Extension.LunrFilter=a.extend({ref:"id",fields:null,initialize:function(e){a.prototype.initialize.apply(this,arguments),this.ref=e.ref||this.ref;var t=this.collection;this.listenTo(t,"add",this.addToIndex),this.listenTo(t,"remove",this.removeFromIndex),this.listenTo(t,"reset",this.resetIndex),this.listenTo(t,"change",this.updateIndex),this.resetIndex(t)},resetIndex:function(t,i){if(i=e.extend({reindex:!0},i||{}),i.reindex){var s=this;this.index=n(function(){e.each(s.fields,function(e,t){this.field(t,e),this.ref(s.ref)},this)}),t.each(function(e){this.addToIndex(e)},this)}},addToIndex:function(e){var t=this.index,i=e.toJSON();t.documentStore.has(i[this.ref])?t.update(i):t.add(i)},removeFromIndex:function(e){var t=this.index,i=e.toJSON();t.documentStore.has(i[this.ref])&&t.remove(i)},updateIndex:function(t){var i=t.changedAttributes();i&&!e.isEmpty(e.intersection(e.keys(this.fields),e.keys(i)))&&this.index.update(t.toJSON())},search:function(){for(var e=this.index.search(this.searchBox().value),t=[],i=0;i|Array.|Array.} options.columns - Column metadata. @param {Backbone.Collection} options.collection @param {boolean} [options.fastForwardHandleLabels] Whether to render fast forward buttons. */ initialize: function (options) { - Backgrid.requireOptions(options, ["columns", "collection"]); + Backgrid.requireOptions(options, ["collection"]); - this.columns = options.columns; - if (!(this.columns instanceof Backbone.Collection)) { - this.columns = new Backgrid.Columns(this.columns); - } - - var columns = this.columns; - this.listenTo(columns, "add", this.render); - this.listenTo(columns, "remove", this.render); - this.listenTo(columns, "change:renderable", this.render); var collection = this.collection; var fullCollection = collection.fullCollection; if (fullCollection) { @@ -91,32 +80,38 @@ */ changePage: function (e) { e.preventDefault(); - var target = e.target; - var label = target.textContent || target.innerText; - var ffLabels = this.fastForwardHandleLabels; - - var collection = this.collection; - if (ffLabels) { - switch (label) { - case ffLabels.first: - collection.getFirstPage(); - return; - case ffLabels.prev: - if (collection.hasPrevious()) collection.getPreviousPage(); - return; - case ffLabels.next: - if (collection.hasNext()) collection.getNextPage(); - return; - case ffLabels.last: - collection.getLastPage(); - return; + var target = e.target; + var li = target.parentNode; + + if (!li.classList.contains("active") && li.classList.contains("disabled")) { + + var label = target.textContent || target.innerText; + var ffLabels = this.fastForwardHandleLabels; + var collection = this.collection; + + if (ffLabels) { + switch (label) { + case ffLabels.first: + collection.getFirstPage(); + return; + case ffLabels.prev: + if (collection.hasPrevious()) collection.getPreviousPage(); + return; + case ffLabels.next: + if (collection.hasNext()) collection.getNextPage(); + return; + case ffLabels.last: + collection.getLastPage(); + return; + + } } - } - var state = collection.state; - var pageIndex = label * 1; - collection.getPage(state.firstPage === 0 ? pageIndex - 1 : pageIndex); + var state = collection.state; + var pageIndex = +label; + collection.getPage(state.firstPage === 0 ? pageIndex - 1 : pageIndex); + } }, /** @@ -132,12 +127,13 @@ var state = collection.state; // convert all indices to 0-based here - var lastPage = state.lastPage ? state.lastPage : state.firstPage; - lastPage = state.firstPage === 0 ? lastPage : lastPage - 1; - var currentPage = state.firstPage === 0 ? state.currentPage : state.currentPage - 1; + var firstPage = state.firstPage; + var lastPage = +state.lastPage; + lastPage = Math.max(0, firstPage ? lastPage - 1 : lastPage); + var currentPage = Math.max(state.currentPage, state.firstPage); + currentPage = firstPage ? currentPage - 1 : currentPage; var windowStart = Math.floor(currentPage / this.windowSize) * this.windowSize; - var windowEnd = windowStart + this.windowSize; - windowEnd = windowEnd <= lastPage ? windowEnd : lastPage + 1; + var windowEnd = Math.min(lastPage + 1, windowStart + this.windowSize); if (collection.mode !== "infinite") { for (var i = windowStart; i < windowEnd; i++) { @@ -185,8 +181,7 @@ }, /** - Render the paginator handles inside an unordered list placed inside a - cell that spans all the columns. + Render the paginator handles inside an unordered list. */ render: function () { this.empty(); diff --git a/lib/extensions/paginator/backgrid-paginator.min.js b/lib/extensions/paginator/backgrid-paginator.min.js index 733805e1..9b19abea 100644 --- a/lib/extensions/paginator/backgrid-paginator.min.js +++ b/lib/extensions/paginator/backgrid-paginator.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,s){"use strict";s.Extension.Paginator=s.View.extend({className:"backgrid-paginator",windowSize:10,fastForwardHandleLabels:{first:"《",prev:"〈",next:"〉",last:"》"},template:e.template(''),events:{"click a":"changePage"},initialize:function(e){s.requireOptions(e,["columns","collection"]),this.columns=e.columns,this.columns instanceof t.Collection||(this.columns=new s.Columns(this.columns));var i=this.columns;this.listenTo(i,"add",this.render),this.listenTo(i,"remove",this.render),this.listenTo(i,"change:renderable",this.render);var a=this.collection,n=a.fullCollection;n?(this.listenTo(n,"add",this.render),this.listenTo(n,"remove",this.render),this.listenTo(n,"reset",this.render)):(this.listenTo(a,"add",this.render),this.listenTo(a,"remove",this.render),this.listenTo(a,"reset",this.render))},changePage:function(e){e.preventDefault();var t=e.target,s=t.textContent||t.innerText,i=this.fastForwardHandleLabels,a=this.collection;if(i)switch(s){case i.first:return a.getFirstPage(),void 0;case i.prev:return a.hasPrevious()&&a.getPreviousPage(),void 0;case i.next:return a.hasNext()&&a.getNextPage(),void 0;case i.last:return a.getLastPage(),void 0}var n=a.state,l=1*s;a.getPage(0===n.firstPage?l-1:l)},makeHandles:function(){var e=[],t=this.collection,s=t.state,i=s.lastPage?s.lastPage:s.firstPage;i=0===s.firstPage?i:i-1;var a=0===s.firstPage?s.currentPage:s.currentPage-1,n=Math.floor(a/this.windowSize)*this.windowSize,l=n+this.windowSize;if(l=i>=l?l:i+1,"infinite"!==t.mode)for(var r=n;l>r;r++)e.push({label:r+1,title:"No. "+(r+1),className:a===r?"active":void 0});var o=this.fastForwardHandleLabels;return o&&(o.prev&&e.unshift({label:o.prev,className:t.hasPrevious()?void 0:"disabled"}),o.first&&e.unshift({label:o.first,className:t.hasPrevious()?void 0:"disabled"}),o.next&&e.push({label:o.next,className:t.hasNext()?void 0:"disabled"}),o.last&&e.push({label:o.last,className:t.hasNext()?void 0:"disabled"})),e},render:function(){return this.empty(),this.el.innerHTML=this.template({handles:this.makeHandles()}),this.delegateEvents(),this}})})(_,Backbone,Backgrid); \ No newline at end of file +(function(e,t,a){"use strict";a.Extension.Paginator=a.View.extend({className:"backgrid-paginator",windowSize:10,fastForwardHandleLabels:{first:"《",prev:"〈",next:"〉",last:"》"},template:e.template(''),events:{"click a":"changePage"},initialize:function(e){a.requireOptions(e,["collection"]);var t=this.collection,i=t.fullCollection;i?(this.listenTo(i,"add",this.render),this.listenTo(i,"remove",this.render),this.listenTo(i,"reset",this.render)):(this.listenTo(t,"add",this.render),this.listenTo(t,"remove",this.render),this.listenTo(t,"reset",this.render))},changePage:function(e){e.preventDefault();var t=e.target,a=t.parentNode;if(!a.classList.contains("active")&&a.classList.contains("disabled")){var i=t.textContent||t.innerText,s=this.fastForwardHandleLabels,n=this.collection;if(s)switch(i){case s.first:return n.getFirstPage(),void 0;case s.prev:return n.hasPrevious()&&n.getPreviousPage(),void 0;case s.next:return n.hasNext()&&n.getNextPage(),void 0;case s.last:return n.getLastPage(),void 0}var l=n.state,r=+i;n.getPage(l.firstPage===0?r-1:r)}},makeHandles:function(){var e=[],t=this.collection,a=t.state,i=a.firstPage,s=+a.lastPage;s=Math.max(0,i?s-1:s);var n=Math.max(a.currentPage,a.firstPage);n=i?n-1:n;var l=Math.floor(n/this.windowSize)*this.windowSize,r=Math.min(s+1,l+this.windowSize);if(t.mode!=="infinite")for(var o=l;r>o;o++)e.push({label:o+1,title:"No. "+(o+1),className:n===o?"active":void 0});var d=this.fastForwardHandleLabels;return d&&(d.prev&&e.unshift({label:d.prev,className:t.hasPrevious()?void 0:"disabled"}),d.first&&e.unshift({label:d.first,className:t.hasPrevious()?void 0:"disabled"}),d.next&&e.push({label:d.next,className:t.hasNext()?void 0:"disabled"}),d.last&&e.push({label:d.last,className:t.hasNext()?void 0:"disabled"})),e},render:function(){return this.empty(),this.el.innerHTML=this.template({handles:this.makeHandles()}),this.delegateEvents(),this}})})(_,Backbone,Backgrid); \ No newline at end of file diff --git a/lib/extensions/select-all/backgrid-select-all.min.js b/lib/extensions/select-all/backgrid-select-all.min.js index 0ad0d699..56422dfb 100644 --- a/lib/extensions/select-all/backgrid-select-all.min.js +++ b/lib/extensions/select-all/backgrid-select-all.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,i){var n=i.Extension.SelectRowCell=i.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(e){i.requireOptions(e,["model","column"]),this.column=e.column,this.column instanceof i.Column||(this.column=new i.Column(this.column)),this.listenTo(this.model,"backgrid:select",function(e,t){this.checkbox().checked=t})},checkbox:function(){return this.el.querySelector("input[type=checkbox]")},enterEditMode:function(){this.checkbox().focus()},exitEditMode:function(){this.checkbox().blur()},onKeydown:function(e){var t=new i.Command(e);return t.passThru()?!0:(t.cancel()?(e.stopPropagation(),this.checkbox().blur()):(t.save()||t.moveLeft()||t.moveRight()||t.moveUp()||t.moveDown())&&(e.preventDefault(),e.stopPropagation(),this.model.trigger("backgrid:edited",this.model,this.column,t)),void 0)},onChange:function(e){this.model.trigger("backgrid:selected",this.model,$(e.target).prop("checked"))},render:function(){return this.empty().el.innerHTML='',this.delegateEvents(),this}}),c=i.Extension.SelectAllHeaderCell=n.extend({className:"select-all-header-cell",tagName:"th",initialize:function(e){i.requireOptions(e,["column","collection"]),this.column=e.column,this.column instanceof i.Column||(this.column=new i.Column(this.column));var t=this.collection,n=this.selectedModels={};this.listenTo(t,"backgrid:selected",function(e,t){t?n[e.id||e.cid]=e:(delete n[e.id||e.cid],this.checkbox().checked=!1)}),this.listenTo(t,"remove",function(e){delete n[e.cid]}),this.listenTo(t,"backgrid:refresh",function(){this.checkbox().checked=!1;for(var e=0;t.length>e;e++){var i=t.at(e);n[i.id||i.cid]&&i.trigger("backgrid:select",i,!0)}})},onChange:function(e){var t=$(e.target).prop("checked"),i=this.collection;i.each(function(e){e.trigger("backgrid:select",e,t)})}});i.Grid.prototype.getSelectedModels=function(){for(var e,t=this.header.row.cells,i=0,n=t.length;n>i;i++){var o=t[i];if(o instanceof c){e=o;break}}var l=[];if(e)for(var s in e.selectedModels)l.push(this.collection.get(s));return l}})(_,Backbone,Backgrid); \ No newline at end of file +(function(e,t,i){var n=i.Extension.SelectRowCell=i.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(e){i.requireOptions(e,["model","column"]),this.column=e.column,this.column instanceof i.Column||(this.column=new i.Column(this.column)),this.listenTo(this.model,"backgrid:select",function(e,t){this.checkbox().checked=t})},checkbox:function(){return this.el.querySelector("input[type=checkbox]")},enterEditMode:function(){this.checkbox().focus()},exitEditMode:function(){this.checkbox().blur()},onKeydown:function(e){var t=new i.Command(e);return t.passThru()?!0:(t.cancel()?(e.stopPropagation(),this.checkbox().blur()):(t.save()||t.moveLeft()||t.moveRight()||t.moveUp()||t.moveDown())&&(e.preventDefault(),e.stopPropagation(),this.model.trigger("backgrid:edited",this.model,this.column,t)),void 0)},onChange:function(e){this.model.trigger("backgrid:selected",this.model,$(e.target).prop("checked"))},render:function(){return this.empty().el.innerHTML='',this.delegateEvents(),this}}),c=i.Extension.SelectAllHeaderCell=n.extend({className:"select-all-header-cell",tagName:"th",initialize:function(e){i.requireOptions(e,["column","collection"]),this.column=e.column,this.column instanceof i.Column||(this.column=new i.Column(this.column));var t=this.collection,n=this.selectedModels={};this.listenTo(t,"backgrid:selected",function(e,t){t?n[e.id||e.cid]=e:(delete n[e.id||e.cid],this.checkbox().checked=!1)}),this.listenTo(t,"remove",function(e){delete n[e.cid]}),this.listenTo(t,"backgrid:refresh",function(){this.checkbox().checked=!1;for(var e=0;ei;i++){var o=t[i];if(o instanceof c){e=o;break}}var l=[];if(e)for(var s in e.selectedModels)l.push(this.collection.get(s));return l}})(_,Backbone,Backgrid); \ No newline at end of file diff --git a/lib/extensions/text-cell/backgrid-text-cell.js b/lib/extensions/text-cell/backgrid-text-cell.js index 4ad93fae..100977b5 100644 --- a/lib/extensions/text-cell/backgrid-text-cell.js +++ b/lib/extensions/text-cell/backgrid-text-cell.js @@ -35,8 +35,9 @@ /** @property */ events: { - "submit": "save", - "hide": "cancel", + "keydown textarea": "clearError", + "submit": "saveOrCancel", + "hide": "saveOrCancel", "hidden": "close", "shown": "focus" }, @@ -68,17 +69,22 @@ }, /** - Event handler. Saves the text in the text area to the model. + Event handler. Saves the text in the text area to the model when + submitting. When cancelling, if the text area is dirty, a confirmation + dialog will pop up. If the user clicks confirm, the text will be saved to + the model. - Triggers a Backbone `backgrid:error` event along with the editor as the - parameter if the value cannot be converted. Classes listening to the - `backgrid:error` event, usually the Cell classes, should respond - appropriately, usually by rendering some kind of error feedback. + Triggers a Backbone `backgrid:error` event from the model along with the + model, column and the existing value as the parameters if the value + cannot be converted. @param {Event} e */ - save: function (e) { - if (e) e.preventDefault(); + saveOrCancel: function (e) { + if (e && e.type == "submit") { + e.preventDefault(); + e.stopPropagation(); + } var model = this.model; var column = this.column; @@ -87,31 +93,31 @@ if (_.isUndefined(newValue)) { model.trigger("backgrid:error", model, column, val); + + if (e) { + e.preventDefault(); + e.stopPropagation(); + } } - else { + else if (!e || e.type == "submit" || + (e.type == "hide" && + newValue !== (this.model.get(this.column.get("name")) || '').replace(/\r/g, '') && + window.confirm("Would you like to save your changes?"))) { + model.set(column.get("name"), newValue); this.$el.modal("hide"); } + else if (e.type != "hide") this.$el.modal("hide"); }, /** - Event handler. Revert the text in the model after asking for confirmation - if dirty, otherwise just close the editor. - - @param {Event} e - */ - cancel: function (e) { - - var content = this.formatter.toRaw(this.$el.find("textarea").val()); - - // Dirty - if (content !== (this.model.get(this.column.get("name")) || '').replace(/\r/g, '') && - window.confirm("Would you like to save your changes?")) { - e.preventDefault(); - e.stopPropagation(); - return this.save(); + Clears the error class on the parent cell. + */ + clearError: _.debounce(function () { + if (!_.isUndefined(this.formatter.toRaw(this.$el.find("textarea").val()))) { + this.$el.parent().removeClass("error"); } - }, + }, 150), /** Triggers a `backgrid:edited` event along with the cell editor as the diff --git a/lib/extensions/text-cell/backgrid-text-cell.min.js b/lib/extensions/text-cell/backgrid-text-cell.min.js index 05acfeb7..d61ef3ed 100644 --- a/lib/extensions/text-cell/backgrid-text-cell.min.js +++ b/lib/extensions/text-cell/backgrid-text-cell.min.js @@ -5,4 +5,4 @@ Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors Licensed under the MIT @license. */ -(function(e,t,o,s,a){var i=a.Extension.TextareaEditor=a.CellEditor.extend({use$:!0,tagName:"div",className:"modal hide fade",template:o.template('
    '),cols:80,rows:10,events:{submit:"save",hide:"cancel",hidden:"close",shown:"focus"},modalOptions:{backdrop:!1},render:function(){return this.$el.html(t(this.template({column:this.column,cols:this.cols,rows:this.rows,content:this.formatter.fromRaw(this.model.get(this.column.get("name")))}))),this.delegateEvents(),this.$el.modal(this.modalOptions),this},save:function(e){e&&e.preventDefault();var t=this.model,s=this.column,a=this.$el.find("textarea").val(),i=this.formatter.toRaw(a);o.isUndefined(i)?t.trigger("backgrid:error",t,s,a):(t.set(s.get("name"),i),this.$el.modal("hide"))},cancel:function(t){var o=this.formatter.toRaw(this.$el.find("textarea").val());return o!==(this.model.get(this.column.get("name"))||"").replace(/\r/g,"")&&e.confirm("Would you like to save your changes?")?(t.preventDefault(),t.stopPropagation(),this.save()):void 0},close:function(e){var t=this.model;t.trigger("backgrid:edited",t,this.column,new a.Command(e))},focus:function(){this.$el.find("textarea").focus()}});a.Extension.TextCell=a.StringCell.extend({className:"text-cell",editor:i})})(window,jQuery,_,Backbone,Backgrid); \ No newline at end of file +(function(e,t,o,a,s){var i=s.Extension.TextareaEditor=s.CellEditor.extend({use$:!0,tagName:"div",className:"modal hide fade",template:o.template('
    '),cols:80,rows:10,events:{"keydown textarea":"clearError",submit:"saveOrCancel",hide:"saveOrCancel",hidden:"close",shown:"focus"},modalOptions:{backdrop:!1},render:function(){return this.$el.html(t(this.template({column:this.column,cols:this.cols,rows:this.rows,content:this.formatter.fromRaw(this.model.get(this.column.get("name")))}))),this.delegateEvents(),this.$el.modal(this.modalOptions),this},saveOrCancel:function(t){t&&t.type=="submit"&&(t.preventDefault(),t.stopPropagation());var a=this.model,s=this.column,i=this.$el.find("textarea").val(),l=this.formatter.toRaw(i);o.isUndefined(l)?(a.trigger("backgrid:error",a,s,i),t&&(t.preventDefault(),t.stopPropagation())):!t||t.type=="submit"||t.type=="hide"&&l!==(this.model.get(this.column.get("name"))||"").replace(/\r/g,"")&&e.confirm("Would you like to save your changes?")?(a.set(s.get("name"),l),this.$el.modal("hide")):t.type!="hide"&&this.$el.modal("hide")},clearError:o.debounce(function(){o.isUndefined(this.formatter.toRaw(this.$el.find("textarea").val()))||this.$el.parent().removeClass("error")},150),close:function(e){var t=this.model;t.trigger("backgrid:edited",t,this.column,new s.Command(e))},focus:function(){this.$el.find("textarea").focus()}});s.Extension.TextCell=s.StringCell.extend({className:"text-cell",editor:i})})(window,jQuery,_,Backbone,Backgrid); \ No newline at end of file diff --git a/src/cell.js b/src/cell.js index 6af118b5..b1f16cb6 100644 --- a/src/cell.js +++ b/src/cell.js @@ -774,7 +774,7 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ text: optionText, value: optionValue, selected: selectedValues.indexOf(optionValue) > -1 - })); + }); } else if (_.isObject(optionValue)) { optgroupName = optionValue.name; @@ -919,8 +919,6 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ try { if (!_.isArray(optionValues) || _.isEmpty(optionValues)) throw new TypeError; - var doc = window.document; - for (var k = 0; k < rawData.length; k++) { var rawDatum = rawData[k]; @@ -931,10 +929,6 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ var optionText = optionValue[0]; var optionValue = optionValue[1]; - if (optionValue == rawData) { - this.el.appendChild(doc.createTextNode(optionText)); - break; - if (optionValue == rawDatum) selectedText.push(optionText); } else if (_.isObject(optionValue)) { @@ -953,7 +947,7 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ } } - this.$el.append(selectedText.join(this.delimiter)); + this.el.appendChild(window.document.createTextNode(selectedText.join(this.delimiter))); } catch (ex) { if (ex instanceof TypeError) { From 36e86e2dbefad01604b9e9e19ef7140118241266 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Sat, 11 May 2013 23:04:59 +0800 Subject: [PATCH 07/31] More fixes failing tests down to 11 --- ... data-b7c77fd81ad6475636218aa47d9137cc.js} | 24 ---- api/index.html | 5 +- api/output/Backgrid.Body.js | 10 +- api/output/Backgrid.BooleanCell.js | 10 +- api/output/Backgrid.BooleanCellEditor.js | 10 +- api/output/Backgrid.Cell.js | 10 +- api/output/Backgrid.CellEditor.js | 10 +- api/output/Backgrid.DateCell.js | 10 +- api/output/Backgrid.DatetimeCell.js | 10 +- api/output/Backgrid.EmailCell.js | 10 +- api/output/Backgrid.EmptyRow.js | 10 +- .../Backgrid.Extension.ClientSideFilter.js | 2 +- api/output/Backgrid.Extension.LunrFilter.js | 2 +- api/output/Backgrid.Extension.MomentCell.js | 10 +- api/output/Backgrid.Extension.Select2Cell.js | 10 +- .../Backgrid.Extension.Select2CellEditor.js | 10 +- .../Backgrid.Extension.SelectAllHeaderCell.js | 10 +- .../Backgrid.Extension.SelectRowCell.js | 10 +- api/output/Backgrid.Extension.TextCell.js | 10 +- .../Backgrid.Extension.TextareaEditor.js | 10 +- api/output/Backgrid.Footer.js | 10 +- api/output/Backgrid.Grid.js | 10 +- api/output/Backgrid.Header.js | 10 +- api/output/Backgrid.HeaderCell.js | 10 +- api/output/Backgrid.HeaderRow.js | 10 +- api/output/Backgrid.InputCellEditor.js | 10 +- api/output/Backgrid.IntegerCell.js | 10 +- api/output/Backgrid.NumberCell.js | 10 +- api/output/Backgrid.Row.js | 10 +- api/output/Backgrid.SelectCell.js | 10 +- api/output/Backgrid.SelectCellEditor.js | 10 +- api/output/Backgrid.StringCell.js | 10 +- api/output/Backgrid.TimeCell.js | 10 +- api/output/Backgrid.UriCell.js | 10 +- api/output/Backgrid.View.js | 107 ------------------ lib/backgrid.js | 32 +++--- lib/backgrid.min.js | 2 +- lib/extensions/filter/backgrid-filter.js | 5 +- lib/extensions/filter/backgrid-filter.min.js | 2 +- src/body.js | 2 +- src/cell.js | 2 +- src/extensions/filter/backgrid-filter.js | 5 +- src/preamble.js | 24 ++-- src/row.js | 2 +- test/extensions/filter.js | 4 +- 45 files changed, 75 insertions(+), 445 deletions(-) rename api/{data-d01f2dc8b037d0f00a232a7939f15078.js => data-b7c77fd81ad6475636218aa47d9137cc.js} (99%) delete mode 100644 api/output/Backgrid.View.js diff --git a/api/data-d01f2dc8b037d0f00a232a7939f15078.js b/api/data-b7c77fd81ad6475636218aa47d9137cc.js similarity index 99% rename from api/data-d01f2dc8b037d0f00a232a7939f15078.js rename to api/data-b7c77fd81ad6475636218aa47d9137cc.js index 70b0f620..f385f108 100644 --- a/api/data-d01f2dc8b037d0f00a232a7939f15078.js +++ b/api/data-b7c77fd81ad6475636218aa47d9137cc.js @@ -253,12 +253,6 @@ Docs = { "private": null, "icon": "icon-class" }, - { - "name": "Backgrid.View", - "extends": null, - "private": null, - "icon": "icon-class" - }, { "name": "Backgrid.Row", "extends": "Backgrid.View", @@ -2534,24 +2528,6 @@ Docs = { }, "sort": 3 }, - { - "name": "View", - "fullName": "Backgrid.View", - "icon": "icon-class", - "url": "#!/api/Backgrid.View", - "meta": { - }, - "sort": 1 - }, - { - "name": "constructor", - "fullName": "Backgrid.View.constructor", - "icon": "icon-method", - "url": "#!/api/Backgrid.View-method-constructor", - "meta": { - }, - "sort": 3 - }, { "name": "Row", "fullName": "Backgrid.Row", diff --git a/api/index.html b/api/index.html index 3ad6abc8..297e13a7 100644 --- a/api/index.html +++ b/api/index.html @@ -12,7 +12,7 @@ - + @@ -76,7 +76,6 @@

    Headers

    Others