diff --git a/.gitignore b/.gitignore
index cc49dab..1cc5b6e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@ src/*.map
*~
*.diff
*.patch
-.DS_Store
\ No newline at end of file
+.DS_Store
+settings.json
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3c907f4..a3c5e48 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,18 @@
# Changelog
+## 1.3.1
+
+### Enhancements & Features
+- Replaced href attributes in order to prevent hash tags so *angular JS* works proper; see issue [#69](http://github.com/rstaib/jquery-bootgrid/issues/69) for more details
+
+### Breaking Changes
+There are no breaking changes but some HTML templates changed during development. In case you want to use the full new feature set be sure you did not override any affected (actionDropDownItem and paginationItem) templates.
+
+## 1.3.0
+
+### Enhancements & Features
+- Option to hide column from the selection box; see issue [#62](http://github.com/rstaib/jquery-bootgrid/issues/62) for more details
+
## 1.2.0
### Enhancements & Features
diff --git a/bower.json b/bower.json
index 39f45f8..856e916 100644
--- a/bower.json
+++ b/bower.json
@@ -13,7 +13,7 @@
"accessibility",
"bootstrap"
],
- "version": "1.2.0-rc",
+ "version": "1.3.1",
"authors": [
{
"name": "Rafael Staib",
diff --git a/demo/index.htm b/demo/index.htm
index 2b8759d..ae13225 100644
--- a/demo/index.htm
+++ b/demo/index.htm
@@ -70,6 +70,7 @@
Received
Link
Status
+ Hidden
@@ -79,6 +80,7 @@
11.12.2014
Link
999
+ Hidden value 1
2
@@ -86,6 +88,7 @@
12.12.2014
Link
999
+ Hidden value 1
3
@@ -93,6 +96,7 @@
10.12.2014
Link
2
+ Hidden value 1
4
@@ -100,6 +104,7 @@
12.08.2014
Link
999
+ Hidden value 1
5
@@ -107,6 +112,7 @@
12.06.2014
Link
3
+ Hidden value 1
6
@@ -114,6 +120,7 @@
12.12.2014
Link
999
+ Hidden value 1
7
@@ -121,6 +128,7 @@
12.11.2014
Link
999
+ Hidden value 1
8
@@ -128,6 +136,7 @@
15.12.2014
Link
999
+ Hidden value 1
9
@@ -135,6 +144,7 @@
24.12.2014
Link
0
+ Hidden value 1
10
@@ -142,6 +152,7 @@
14.12.2014
Link
1
+ Hidden value 1
11
@@ -149,6 +160,7 @@
12.12.2014
Link
999
+ Hidden value 1
@@ -177,7 +189,7 @@
return "" + column.id + ": " + row.id + " ";
}
},
- rowCount: [-1, 25, 50, 75]
+ rowCount: [-1, 10, 50, 75]
});
}
diff --git a/dist/jQuery.Bootgrid.1.2.0-rc.nupkg b/dist/jQuery.Bootgrid.1.2.0-rc.nupkg
deleted file mode 100644
index cbce53a..0000000
Binary files a/dist/jQuery.Bootgrid.1.2.0-rc.nupkg and /dev/null differ
diff --git a/dist/jQuery.Bootgrid.1.3.1.nupkg b/dist/jQuery.Bootgrid.1.3.1.nupkg
new file mode 100644
index 0000000..c430a89
Binary files /dev/null and b/dist/jQuery.Bootgrid.1.3.1.nupkg differ
diff --git a/dist/jquery.bootgrid-1.2.0-rc.zip b/dist/jquery.bootgrid-1.2.0-rc.zip
deleted file mode 100644
index f7fcd3b..0000000
Binary files a/dist/jquery.bootgrid-1.2.0-rc.zip and /dev/null differ
diff --git a/dist/jquery.bootgrid-1.3.1.zip b/dist/jquery.bootgrid-1.3.1.zip
new file mode 100644
index 0000000..61cbe12
Binary files /dev/null and b/dist/jquery.bootgrid-1.3.1.zip differ
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index 4d2a324..13512d9 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.2.0-rc - 04/17/2015
+ * jQuery Bootgrid v1.3.1 - 09/11/2015
* Copyright (c) 2014-2015 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index d002cd5..c120aa0 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.2.0-rc - 04/17/2015
+ * jQuery Bootgrid v1.3.1 - 09/11/2015
* Copyright (c) 2014-2015 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.min.js b/dist/jquery.bootgrid.fa.min.js
index a8aa43e..5e78cfb 100644
--- a/dist/jquery.bootgrid.fa.min.js
+++ b/dist/jquery.bootgrid.fa.min.js
@@ -1,6 +1,6 @@
/*!
- * jQuery Bootgrid v1.2.0-rc - 04/17/2015
+ * jQuery Bootgrid v1.3.1 - 09/11/2015
* Copyright (c) 2014-2015 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
-!function(a){"use strict";a.extend(a.fn.bootgrid.Constructor.defaults.css,{icon:"icon fa",iconColumns:"fa-th-list",iconDown:"fa-sort-desc",iconRefresh:"fa-refresh",iconSearch:"fa-search",iconUp:"fa-sort-asc"})}(jQuery,window);
\ No newline at end of file
+!function(a,b,c){"use strict";a.extend(a.fn.bootgrid.Constructor.defaults.css,{icon:"icon fa",iconColumns:"fa-th-list",iconDown:"fa-sort-desc",iconRefresh:"fa-refresh",iconSearch:"fa-search",iconUp:"fa-sort-asc"})}(jQuery,window);
\ No newline at end of file
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 3a6163a..4f27d44 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.2.0-rc - 04/17/2015
+ * jQuery Bootgrid v1.3.1 - 09/11/2015
* Copyright (c) 2014-2015 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -126,6 +126,7 @@
searchable: !(data.searchable === false), // default: true
sortable: !(data.sortable === false), // default: true
visible: !(data.visible === false), // default: true
+ visibleInSelection: !(data.visibleInSelection === false), // default: true
width: ($.isNumeric(data.width)) ? data.width + "px" :
(typeof(data.width) === "string") ? data.width : null
};
@@ -382,27 +383,30 @@
$.each(this.columns, function (i, column)
{
- var item = $(tpl.actionDropDownCheckboxItem.resolve(getParams.call(that,
- { name: column.id, label: column.text, checked: column.visible })))
- .on("click" + namespace, selector, function (e)
- {
- e.stopPropagation();
-
- var $this = $(this),
- checkbox = $this.find(checkboxSelector);
- if (!checkbox.prop("disabled"))
+ if (column.visibleInSelection)
+ {
+ var item = $(tpl.actionDropDownCheckboxItem.resolve(getParams.call(that,
+ { name: column.id, label: column.text, checked: column.visible })))
+ .on("click" + namespace, selector, function (e)
{
- column.visible = checkbox.prop("checked");
- var enable = that.columns.where(isVisible).length > 1;
- $this.parents(itemsSelector).find(selector + ":has(" + checkboxSelector + ":checked)")
- ._bgEnableAria(enable).find(checkboxSelector)._bgEnableField(enable);
-
- that.element.find("tbody").empty(); // Fixes an column visualization bug
- renderTableHeader.call(that);
- loadData.call(that);
- }
- });
- dropDown.find(getCssSelector(css.dropDownMenuItems)).append(item);
+ e.stopPropagation();
+
+ var $this = $(this),
+ checkbox = $this.find(checkboxSelector);
+ if (!checkbox.prop("disabled"))
+ {
+ column.visible = checkbox.prop("checked");
+ var enable = that.columns.where(isVisible).length > 1;
+ $this.parents(itemsSelector).find(selector + ":has(" + checkboxSelector + ":checked)")
+ ._bgEnableAria(enable).find(checkboxSelector)._bgEnableField(enable);
+
+ that.element.find("tbody").empty(); // Fixes an column visualization bug
+ renderTableHeader.call(that);
+ loadData.call(that);
+ }
+ });
+ dropDown.find(getCssSelector(css.dropDownMenuItems)).append(item);
+ }
});
actions.append(dropDown);
}
@@ -491,16 +495,17 @@
}
}
- function renderPaginationItem(list, uri, text, markerCss)
+ function renderPaginationItem(list, page, text, markerCss)
{
var that = this,
tpl = this.options.templates,
css = this.options.css,
- values = getParams.call(this, { css: markerCss, text: text, uri: "#" + uri }),
+ values = getParams.call(this, { css: markerCss, text: text, page: page }),
item = $(tpl.paginationItem.resolve(values))
.on("click" + namespace, getCssSelector(css.paginationButton), function (e)
{
e.stopPropagation();
+ e.preventDefault();
var $this = $(this),
parent = $this.parent();
@@ -512,8 +517,8 @@
next: that.current + 1,
last: that.totalPages
};
- var command = $this.attr("href").substr(1);
- that.current = commandList[command] || +command; // + converts string to int
+ var command = $this.data("page");
+ that.current = commandList[command] || command;
loadData.call(that);
}
$this.trigger("blur");
@@ -546,14 +551,14 @@
$.each(rowCountList, function (index, value)
{
var item = $(tpl.actionDropDownItem.resolve(getParams.call(that,
- { text: getText(value), uri: "#" + value })))
+ { text: getText(value), action: value })))
._bgSelectAria(value === that.rowCount)
.on("click" + namespace, menuItemSelector, function (e)
{
e.preventDefault();
var $this = $(this),
- newRowCount = +$this.attr("href").substr(1);
+ newRowCount = $this.data("action");
if (newRowCount !== that.rowCount)
{
// todo: sophisticated solution needed for calculating which page is selected
@@ -562,7 +567,7 @@
$this.parents(menuItemsSelector).children().each(function ()
{
var $item = $(this),
- currentRowCount = +$item.find(menuItemSelector).attr("href").substr(1);
+ currentRowCount = $item.find(menuItemSelector).data("action");
$item._bgSelectAria(currentRowCount === newRowCount);
});
$this.parents(menuSelector).find(menuTextSelector).text(getText(newRowCount));
@@ -1065,7 +1070,7 @@
multiSort: false,
/**
- * Generall search settings to configure the search field behaviour.
+ * General search settings to configure the search field behaviour.
*
* @property searchSettings
* @type Object
@@ -1106,7 +1111,7 @@
/**
* Ajax request settings that shall be used for server-side communication.
- * All setting can be overridden except data, error, success and url.
+ * All setting except data, error, success and url can be overridden.
* For the full list of settings go to http://api.jquery.com/jQuery.ajax/.
*
* @property ajaxSettings
@@ -1351,7 +1356,7 @@
templates: {
actionButton: "{{ctx.content}} ",
actionDropDown: "",
- actionDropDownItem: "{{ctx.text}} ",
+ actionDropDownItem: "{{ctx.text}} ",
actionDropDownCheckboxItem: " {{ctx.label}} ",
actions: "
",
body: " ",
@@ -1364,7 +1369,7 @@
loading: "{{lbl.loading}} ",
noResults: "{{lbl.noResults}} ",
pagination: "",
- paginationItem: " ",
+ paginationItem: " ",
rawHeaderCell: "{{ctx.content}} ", // Used for the multi select box
row: "{{ctx.cells}} ",
search: "",
@@ -1383,7 +1388,7 @@
{
if (this.options.ajax)
{
- // todo: implement ajax DELETE
+ // todo: implement ajax PUT
}
else
{
@@ -1690,6 +1695,7 @@
*
* @method getColumnSettings
* @return {Array} Returns a list of the column settings.
+ * @since 1.2.0
**/
Grid.prototype.getColumnSettings = function()
{
@@ -1703,6 +1709,7 @@
*
* @method getCurrentPage
* @return {Number} Returns the current page index.
+ * @since 1.2.0
**/
Grid.prototype.getCurrentPage = function()
{
@@ -1716,6 +1723,7 @@
*
* @method getCurrentPage
* @return {Array} Returns the current rows.
+ * @since 1.2.0
**/
Grid.prototype.getCurrentRows = function()
{
@@ -1729,6 +1737,7 @@
*
* @method getRowCount
* @return {Number} Returns the row count per page.
+ * @since 1.2.0
**/
Grid.prototype.getRowCount = function()
{
@@ -1742,6 +1751,7 @@
*
* @method getSearchPhrase
* @return {String} Returns the actual search phrase.
+ * @since 1.2.0
**/
Grid.prototype.getSearchPhrase = function()
{
@@ -1755,6 +1765,7 @@
*
* @method getSelectedRows
* @return {Array} Returns all selected rows.
+ * @since 1.2.0
**/
Grid.prototype.getSelectedRows = function()
{
@@ -1768,6 +1779,7 @@
*
* @method getSortDictionary
* @return {Object} Returns the sort dictionary.
+ * @since 1.2.0
**/
Grid.prototype.getSortDictionary = function()
{
@@ -1781,6 +1793,7 @@
*
* @method getTotalPageCount
* @return {Number} Returns the total page count.
+ * @since 1.2.0
**/
Grid.prototype.getTotalPageCount = function()
{
@@ -1794,6 +1807,7 @@
*
* @method getTotalRowCount
* @return {Number} Returns the total row count.
+ * @since 1.2.0
**/
Grid.prototype.getTotalRowCount = function()
{
diff --git a/dist/jquery.bootgrid.min.css b/dist/jquery.bootgrid.min.css
index e25cadc..358c1ac 100644
--- a/dist/jquery.bootgrid.min.css
+++ b/dist/jquery.bootgrid.min.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.2.0-rc - 04/17/2015
+ * jQuery Bootgrid v1.3.1 - 09/11/2015
* Copyright (c) 2014-2015 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/.bootgrid-footer,.bootgrid-header{margin:15px 0}.bootgrid-footer a,.bootgrid-header a{outline:0}.bootgrid-footer .search,.bootgrid-header .search{display:inline-block;margin:0 20px 0 0;vertical-align:middle;width:180px}.bootgrid-footer .search .glyphicon,.bootgrid-header .search .glyphicon{top:0}.bootgrid-footer .search .fa,.bootgrid-header .search .fa{display:table-cell}.bootgrid-footer .search .search-field::-ms-clear,.bootgrid-footer .search.search-field::-ms-clear,.bootgrid-header .search .search-field::-ms-clear,.bootgrid-header .search.search-field::-ms-clear{display:none}.bootgrid-footer .pagination,.bootgrid-header .pagination{margin:0!important}.bootgrid-footer .infoBar,.bootgrid-header .actionBar{text-align:right}.bootgrid-footer .infoBar .btn-group>.btn-group .dropdown-menu,.bootgrid-header .actionBar .btn-group>.btn-group .dropdown-menu{text-align:left}.bootgrid-footer .infoBar .btn-group>.btn-group .dropdown-menu .dropdown-item,.bootgrid-header .actionBar .btn-group>.btn-group .dropdown-menu .dropdown-item{cursor:pointer;display:block;margin:0;padding:3px 20px;white-space:nowrap}.bootgrid-footer .infoBar .btn-group>.btn-group .dropdown-menu .dropdown-item:focus,.bootgrid-footer .infoBar .btn-group>.btn-group .dropdown-menu .dropdown-item:hover,.bootgrid-header .actionBar .btn-group>.btn-group .dropdown-menu .dropdown-item:focus,.bootgrid-header .actionBar .btn-group>.btn-group .dropdown-menu .dropdown-item:hover{color:#262626;text-decoration:none;background-color:#f5f5f5}.bootgrid-footer .infoBar .btn-group>.btn-group .dropdown-menu .dropdown-item .dropdown-item-checkbox,.bootgrid-footer .infoBar .btn-group>.btn-group .dropdown-menu .dropdown-item.dropdown-item-checkbox,.bootgrid-header .actionBar .btn-group>.btn-group .dropdown-menu .dropdown-item .dropdown-item-checkbox,.bootgrid-header .actionBar .btn-group>.btn-group .dropdown-menu .dropdown-item.dropdown-item-checkbox{margin:0 2px 4px 0;vertical-align:middle}.bootgrid-footer .infoBar .btn-group>.btn-group .dropdown-menu .dropdown-item.disabled,.bootgrid-header .actionBar .btn-group>.btn-group .dropdown-menu .dropdown-item.disabled{cursor:not-allowed}.bootgrid-table{table-layout:fixed}.bootgrid-table a{outline:0}.bootgrid-table th>.column-header-anchor{color:#333;cursor:not-allowed;display:block;position:relative;text-decoration:none}.bootgrid-table th>.column-header-anchor.sortable{cursor:pointer}.bootgrid-table th>.column-header-anchor>.text{display:block;margin:0 16px 0 0;overflow:hidden;-ms-text-overflow:ellipsis;-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap}.bootgrid-table th>.column-header-anchor>.icon{display:block;position:absolute;right:0;top:2px}.bootgrid-table th:active,.bootgrid-table th:hover{background:#fafafa}.bootgrid-table td{overflow:hidden;-ms-text-overflow:ellipsis;-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap}.bootgrid-table td.loading,.bootgrid-table td.no-results{background:#fff;text-align:center}.bootgrid-table td.select-cell,.bootgrid-table th.select-cell{text-align:center;width:30px}.bootgrid-table td.select-cell .select-box,.bootgrid-table th.select-cell .select-box{margin:0;outline:0}.table-responsive .bootgrid-table{table-layout:inherit!important}.table-responsive .bootgrid-table td,.table-responsive .bootgrid-table th>.column-header-anchor>.text{overflow:inherit!important;-ms-text-overflow:inherit!important;-o-text-overflow:inherit!important;text-overflow:inherit!important;white-space:inherit!important}
\ No newline at end of file
diff --git a/dist/jquery.bootgrid.min.js b/dist/jquery.bootgrid.min.js
index a2fc89a..b84a714 100644
--- a/dist/jquery.bootgrid.min.js
+++ b/dist/jquery.bootgrid.min.js
@@ -1,6 +1,6 @@
/*!
- * jQuery Bootgrid v1.2.0-rc - 04/17/2015
+ * jQuery Bootgrid v1.3.1 - 09/11/2015
* Copyright (c) 2014-2015 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
-!function(a,b){"use strict";function c(a){function b(b){return c.identifier&&b[c.identifier]===a[c.identifier]}var c=this;return this.rows.contains(b)?!1:(this.rows.push(a),!0)}function d(b){var c=this.footer?this.footer.find(b):a(),d=this.header?this.header.find(b):a();return a.merge(c,d)}function e(b){return b?a.extend({},this.cachedParams,{ctx:b}):this.cachedParams}function f(){var b={current:this.current,rowCount:this.rowCount,sort:this.sortDictionary,searchPhrase:this.searchPhrase},c=this.options.post;return c=a.isFunction(c)?c():c,this.options.requestHandler(a.extend(!0,b,c))}function g(b){return"."+a.trim(b).replace(/\s+/gm,".")}function h(){var b=this.options.url;return a.isFunction(b)?b():b}function i(){this.element.trigger("initialize"+G),l.call(this),this.selection=this.options.selection&&null!=this.identifier,n.call(this),p.call(this),B.call(this),z.call(this),q.call(this),m.call(this),this.element.trigger("initialized"+G)}function j(){this.options.highlightRows}function k(a){return a.visible}function l(){var b=this,c=this.element.find("thead > tr").first(),d=!1;c.children().each(function(){var c=a(this),e=c.data(),f={id:e.columnId,identifier:null==b.identifier&&e.identifier||!1,converter:b.options.converters[e.converter||e.type]||b.options.converters.string,text:c.text(),align:e.align||"left",headerAlign:e.headerAlign||"left",cssClass:e.cssClass||"",headerCssClass:e.headerCssClass||"",formatter:b.options.formatters[e.formatter]||null,order:d||"asc"!==e.order&&"desc"!==e.order?null:e.order,searchable:!(e.searchable===!1),sortable:!(e.sortable===!1),visible:!(e.visible===!1),width:a.isNumeric(e.width)?e.width+"px":"string"==typeof e.width?e.width:null};b.columns.push(f),null!=f.order&&(b.sortDictionary[f.id]=f.order),f.identifier&&(b.identifier=f.id,b.converter=f.converter),b.options.multiSort||null===f.order||(d=!0)})}function m(){function c(a){for(var b,c=new RegExp(e.searchPhrase,e.options.caseSensitive?"g":"gi"),d=0;d-1)return!0;return!1}function d(a,b){e.currentRows=a,o.call(e,b),e.options.keepSelection||(e.selectedRows=[]),x.call(e,a),s.call(e),u.call(e),e.element._bgBusyAria(!1).trigger("loaded"+G)}var e=this;if(this.element._bgBusyAria(!0).trigger("load"+G),E.call(this),this.options.ajax){var g=f.call(this),i=h.call(this);if(null==i||"string"!=typeof i||0===i.length)throw new Error("Url setting must be a none empty string or a function that returns one.");this.xqr&&this.xqr.abort();var j={url:i,data:g,success:function(b){e.xqr=null,"string"==typeof b&&(b=a.parseJSON(b)),b=e.options.responseHandler(b),e.current=b.current,d(b.rows,b.total)},error:function(a,b){e.xqr=null,"abort"!==b&&(t.call(e),e.element._bgBusyAria(!1).trigger("loaded"+G))}};j=a.extend(this.options.ajaxSettings,j),this.xqr=a.ajax(j)}else{var k=this.searchPhrase.length>0?this.rows.where(c):this.rows,l=k.length;-1!==this.rowCount&&(k=k.page(this.current,this.rowCount)),b.setTimeout(function(){d(k,l)},10)}}function n(){if(!this.options.ajax){var b=this,d=this.element.find("tbody > tr");d.each(function(){var d=a(this),e=d.children("td"),f={};a.each(b.columns,function(a,b){f[b.id]=b.converter.from(e.eq(a).text())}),c.call(b,f)}),o.call(this,this.rows.length),F.call(this)}}function o(a){this.total=a,this.totalPages=-1===this.rowCount?1:Math.ceil(this.total/this.rowCount)}function p(){var b=this.options.templates,c=this.element.parent().hasClass(this.options.css.responsiveTable)?this.element.parent():this.element;this.element.addClass(this.options.css.table),0===this.element.children("tbody").length&&this.element.append(b.body),1&this.options.navigation&&(this.header=a(b.header.resolve(e.call(this,{id:this.element._bgId()+"-header"}))),c.before(this.header)),2&this.options.navigation&&(this.footer=a(b.footer.resolve(e.call(this,{id:this.element._bgId()+"-footer"}))),c.after(this.footer))}function q(){if(0!==this.options.navigation){var b=this.options.css,c=g(b.actions),f=d.call(this,c);if(f.length>0){var h=this,i=this.options.templates,j=a(i.actions.resolve(e.call(this)));if(this.options.ajax){var k=i.icon.resolve(e.call(this,{iconCss:b.iconRefresh})),l=a(i.actionButton.resolve(e.call(this,{content:k,text:this.options.labels.refresh}))).on("click"+G,function(a){a.stopPropagation(),h.current=1,m.call(h)});j.append(l)}w.call(this,j),r.call(this,j),D.call(this,f,j)}}}function r(b){if(this.options.columnSelection&&this.columns.length>1){var c=this,d=this.options.css,f=this.options.templates,h=f.icon.resolve(e.call(this,{iconCss:d.iconColumns})),i=a(f.actionDropDown.resolve(e.call(this,{content:h}))),j=g(d.dropDownItem),l=g(d.dropDownItemCheckbox),n=g(d.dropDownMenuItems);a.each(this.columns,function(b,h){var o=a(f.actionDropDownCheckboxItem.resolve(e.call(c,{name:h.id,label:h.text,checked:h.visible}))).on("click"+G,j,function(b){b.stopPropagation();var d=a(this),e=d.find(l);if(!e.prop("disabled")){h.visible=e.prop("checked");var f=c.columns.where(k).length>1;d.parents(n).find(j+":has("+l+":checked)")._bgEnableAria(f).find(l)._bgEnableField(f),c.element.find("tbody").empty(),B.call(c),m.call(c)}});i.find(g(d.dropDownMenuItems)).append(o)}),b.append(i)}}function s(){if(0!==this.options.navigation){var b=g(this.options.css.infos),c=d.call(this,b);if(c.length>0){var f=this.current*this.rowCount,h=a(this.options.templates.infos.resolve(e.call(this,{end:0===this.total||-1===f||f>this.total?this.total:f,start:0===this.total?0:f-this.rowCount+1,total:this.total})));D.call(this,c,h)}}}function t(){var a=this.element.children("tbody").first(),b=this.options.templates,c=this.columns.where(k).length;this.selection&&(c+=1),a.html(b.noResults.resolve(e.call(this,{columns:c})))}function u(){if(0!==this.options.navigation){var b=g(this.options.css.pagination),c=d.call(this,b)._bgShowAria(-1!==this.rowCount);if(-1!==this.rowCount&&c.length>0){var f=this.options.templates,h=this.current,i=this.totalPages,j=a(f.pagination.resolve(e.call(this))),k=i-h,l=-1*(this.options.padding-h),m=k>=this.options.padding?Math.max(l,1):Math.max(l-this.options.padding+k,1),n=2*this.options.padding+1,o=i>=n?n:i;v.call(this,j,"first","«","first")._bgEnableAria(h>1),v.call(this,j,"prev","<","prev")._bgEnableAria(h>1);for(var p=0;o>p;p++){var q=p+m;v.call(this,j,q,q,"page-"+q)._bgEnableAria()._bgSelectAria(q===h)}0===o&&v.call(this,j,1,1,"page-1")._bgEnableAria(!1)._bgSelectAria(),v.call(this,j,"next",">","next")._bgEnableAria(i>h),v.call(this,j,"last","»","last")._bgEnableAria(i>h),D.call(this,c,j)}}}function v(b,c,d,f){var h=this,i=this.options.templates,j=this.options.css,k=e.call(this,{css:f,text:d,uri:"#"+c}),l=a(i.paginationItem.resolve(k)).on("click"+G,g(j.paginationButton),function(b){b.stopPropagation();var c=a(this),d=c.parent();if(!d.hasClass("active")&&!d.hasClass("disabled")){var e={first:1,prev:h.current-1,next:h.current+1,last:h.totalPages},f=c.attr("href").substr(1);h.current=e[f]||+f,m.call(h)}c.trigger("blur")});return b.append(l),l}function w(b){function c(a){return-1===a?d.options.labels.all:a}var d=this,f=this.options.rowCount;if(a.isArray(f)){var h=this.options.css,i=this.options.templates,j=a(i.actionDropDown.resolve(e.call(this,{content:c(this.rowCount)}))),k=g(h.dropDownMenu),l=g(h.dropDownMenuText),n=g(h.dropDownMenuItems),o=g(h.dropDownItemButton);a.each(f,function(b,f){var g=a(i.actionDropDownItem.resolve(e.call(d,{text:c(f),uri:"#"+f})))._bgSelectAria(f===d.rowCount).on("click"+G,o,function(b){b.preventDefault();var e=a(this),f=+e.attr("href").substr(1);f!==d.rowCount&&(d.current=1,d.rowCount=f,e.parents(n).children().each(function(){var b=a(this),c=+b.find(o).attr("href").substr(1);b._bgSelectAria(c===f)}),e.parents(k).find(l).text(c(f)),m.call(d))});j.find(n).append(g)}),b.append(j)}}function x(b){if(b.length>0){var c=this,d=this.options.css,f=this.options.templates,h=this.element.children("tbody").first(),i=!0,j="";a.each(b,function(b,g){var h="",k=' data-row-id="'+(null==c.identifier?b:g[c.identifier])+'"',l="";if(c.selection){var m=-1!==a.inArray(g[c.identifier],c.selectedRows),n=f.select.resolve(e.call(c,{type:"checkbox",value:g[c.identifier],checked:m}));h+=f.cell.resolve(e.call(c,{content:n,css:d.selectCell})),i=i&&m,m&&(l+=d.selected,k+=' aria-selected="true"')}var o=null!=g.status&&c.options.statusMapping[g.status];o&&(l+=o),a.each(c.columns,function(b,i){if(i.visible){var j=a.isFunction(i.formatter)?i.formatter.call(c,i,g):i.converter.to(g[i.id]),k=i.cssClass.length>0?" "+i.cssClass:"";h+=f.cell.resolve(e.call(c,{content:null==j||""===j?" ":j,css:("right"===i.align?d.right:"center"===i.align?d.center:d.left)+k,style:null==i.width?"":"width:"+i.width+";"}))}}),l.length>0&&(k+=' class="'+l+'"'),j+=f.row.resolve(e.call(c,{attr:k,cells:h}))}),c.element.find("thead "+g(c.options.css.selectBox)).prop("checked",i),h.html(j),y.call(this,h)}else t.call(this)}function y(b){var c=this,d=g(this.options.css.selectBox);this.selection&&b.off("click"+G,d).on("click"+G,d,function(b){b.stopPropagation();var d=a(this),e=c.converter.from(d.val());d.prop("checked")?c.select([e]):c.deselect([e])}),b.off("click"+G,"> tr").on("click"+G,"> tr",function(b){b.stopPropagation();var d=a(this),e=null==c.identifier?d.data("row-id"):c.converter.from(d.data("row-id")+""),f=null==c.identifier?c.currentRows[e]:c.currentRows.first(function(a){return a[c.identifier]===e});c.selection&&c.options.rowSelect&&(d.hasClass(c.options.css.selected)?c.deselect([e]):c.select([e])),c.element.trigger("click"+G,[c.columns,f])})}function z(){if(0!==this.options.navigation){var c=this.options.css,f=g(c.search),h=d.call(this,f);if(h.length>0){var i=this,j=this.options.templates,k=null,l="",m=g(c.searchField),n=a(j.search.resolve(e.call(this))),o=n.is(m)?n:n.find(m);o.on("keyup"+G,function(c){c.stopPropagation();var d=a(this).val();(l!==d||13===c.which&&""!==d)&&(l=d,(13===c.which||0===d.length||d.length>=i.options.searchSettings.characters)&&(b.clearTimeout(k),k=b.setTimeout(function(){A.call(i,d)},i.options.searchSettings.delay)))}),D.call(this,h,n)}}}function A(a){this.searchPhrase!==a&&(this.current=1,this.searchPhrase=a,m.call(this))}function B(){var b=this,c=this.element.find("thead > tr"),d=this.options.css,f=this.options.templates,h="",i=this.options.sorting;if(this.selection){var j=this.options.multiSelect?f.select.resolve(e.call(b,{type:"checkbox",value:"all"})):"";h+=f.rawHeaderCell.resolve(e.call(b,{content:j,css:d.selectCell}))}if(a.each(this.columns,function(a,c){if(c.visible){var g=b.sortDictionary[c.id],j=i&&g&&"asc"===g?d.iconUp:i&&g&&"desc"===g?d.iconDown:"",k=f.icon.resolve(e.call(b,{iconCss:j})),l=c.headerAlign,m=c.headerCssClass.length>0?" "+c.headerCssClass:"";h+=f.headerCell.resolve(e.call(b,{column:c,icon:k,sortable:i&&c.sortable&&d.sortable||"",css:("right"===l?d.right:"center"===l?d.center:d.left)+m,style:null==c.width?"":"width:"+c.width+";"}))}}),c.html(h),i){var k=g(d.sortable);c.off("click"+G,k).on("click"+G,k,function(c){c.preventDefault(),C.call(b,a(this)),F.call(b),m.call(b)})}if(this.selection&&this.options.multiSelect){var l=g(d.selectBox);c.off("click"+G,l).on("click"+G,l,function(c){c.stopPropagation(),a(this).prop("checked")?b.select():b.deselect()})}}function C(a){var b=this.options.css,c=g(b.icon),d=a.data("column-id")||a.parents("th").first().data("column-id"),e=this.sortDictionary[d],f=a.find(c);if(this.options.multiSort||(a.parents("tr").first().find(c).removeClass(b.iconDown+" "+b.iconUp),this.sortDictionary={}),e&&"asc"===e)this.sortDictionary[d]="desc",f.removeClass(b.iconUp).addClass(b.iconDown);else if(e&&"desc"===e)if(this.options.multiSort){var h={};for(var i in this.sortDictionary)i!==d&&(h[i]=this.sortDictionary[i]);this.sortDictionary=h,f.removeClass(b.iconDown)}else this.sortDictionary[d]="asc",f.removeClass(b.iconDown).addClass(b.iconUp);else this.sortDictionary[d]="asc",f.addClass(b.iconUp)}function D(b,c){b.each(function(b,d){a(d).before(c.clone(!0)).remove()})}function E(){var a=this;b.setTimeout(function(){if("true"===a.element._bgAria("busy")){var b=a.options.templates,c=a.element.children("thead").first(),d=a.element.children("tbody").first(),f=d.find("tr > td").first(),g=a.element.height()-c.height()-(f.height()+20),h=a.columns.where(k).length;a.selection&&(h+=1),d.html(b.loading.resolve(e.call(a,{columns:h}))),-1!==a.rowCount&&g>0&&d.find("tr > td").css("padding","20px 0 "+g+"px")}},250)}function F(){function a(c,d,e){function f(a){return"asc"===h.order?a:-1*a}e=e||0;var g=e+1,h=b[e];return c[h.id]>d[h.id]?f(1):c[h.id]g?a(c,d,g):0}var b=[];if(!this.options.ajax){for(var c in this.sortDictionary)(this.options.multiSort||0===b.length)&&b.push({id:c,order:this.sortDictionary[c]});b.length>0&&this.rows.sort(a)}}var G=".rs.jquery.bootgrid",H=function(b,c){this.element=a(b),this.origin=this.element.clone(),this.options=a.extend(!0,{},H.defaults,this.element.data(),c);var d=this.options.rowCount=this.element.data().rowCount||c.rowCount||this.options.rowCount;this.columns=[],this.current=1,this.currentRows=[],this.identifier=null,this.selection=!1,this.converter=null,this.rowCount=a.isArray(d)?d[0]:d,this.rows=[],this.searchPhrase="",this.selectedRows=[],this.sortDictionary={},this.total=0,this.totalPages=0,this.cachedParams={lbl:this.options.labels,css:this.options.css,ctx:{}},this.header=null,this.footer=null,this.xqr=null};if(H.defaults={navigation:3,padding:2,columnSelection:!0,rowCount:[10,25,50,-1],selection:!1,multiSelect:!1,rowSelect:!1,keepSelection:!1,highlightRows:!1,sorting:!0,multiSort:!1,searchSettings:{delay:250,characters:1},ajax:!1,ajaxSettings:{method:"POST"},post:{},url:"",caseSensitive:!0,requestHandler:function(a){return a},responseHandler:function(a){return a},converters:{numeric:{from:function(a){return+a},to:function(a){return a+""}},string:{from:function(a){return a},to:function(a){return a}}},css:{actions:"actions btn-group",center:"text-center",columnHeaderAnchor:"column-header-anchor",columnHeaderText:"text",dropDownItem:"dropdown-item",dropDownItemButton:"dropdown-item-button",dropDownItemCheckbox:"dropdown-item-checkbox",dropDownMenu:"dropdown btn-group",dropDownMenuItems:"dropdown-menu pull-right",dropDownMenuText:"dropdown-text",footer:"bootgrid-footer container-fluid",header:"bootgrid-header container-fluid",icon:"icon glyphicon",iconColumns:"glyphicon-th-list",iconDown:"glyphicon-chevron-down",iconRefresh:"glyphicon-refresh",iconSearch:"glyphicon-search",iconUp:"glyphicon-chevron-up",infos:"infos",left:"text-left",pagination:"pagination",paginationButton:"button",responsiveTable:"table-responsive",right:"text-right",search:"search form-group",searchField:"search-field form-control",selectBox:"select-box",selectCell:"select-cell",selected:"active",sortable:"sortable",table:"bootgrid-table table"},formatters:{},labels:{all:"All",infos:"Showing {{ctx.start}} to {{ctx.end}} of {{ctx.total}} entries",loading:"Loading...",noResults:"No results found!",refresh:"Refresh",search:"Search"},statusMapping:{0:"success",1:"info",2:"warning",3:"danger"},templates:{actionButton:'{{ctx.content}} ',actionDropDown:'',actionDropDownItem:'{{ctx.text}} ',actionDropDownCheckboxItem:' {{ctx.label}} ',actions:'
',body:" ",cell:'{{ctx.content}} ',footer:'',header:'',headerCell:'{{ctx.column.text}} {{ctx.icon}} ',icon:' ',infos:'{{lbl.infos}}
',loading:'{{lbl.loading}} ',noResults:'{{lbl.noResults}} ',pagination:'',paginationItem:' ',rawHeaderCell:'{{ctx.content}} ',row:"{{ctx.cells}} ",search:'',select:' '}},H.prototype.append=function(a){if(this.options.ajax);else{for(var b=[],d=0;d0&&(this.options.multiSelect||1!==e.length);)if(c=b.pop(),-1===a.inArray(c,this.selectedRows))for(d=0;d0){var f=g(this.options.css.selectBox),h=this.selectedRows.length>=this.currentRows.length;for(d=0;!this.options.keepSelection&&h&&d tr "+f+":checked").trigger("click"+G),d=0;d tr[data-row-id="'+this.selectedRows[d]+'"]').addClass(this.options.css.selected)._bgAria("selected","true").find(f).prop("checked",!0);this.element.trigger("selected"+G,[e])}}return this},H.prototype.deselect=function(b){if(this.selection){b=b||this.currentRows.propValues(this.identifier);for(var c,d,e,f=[];b.length>0;)if(c=b.pop(),e=a.inArray(c,this.selectedRows),-1!==e)for(d=0;d0){var h=g(this.options.css.selectBox);for(this.element.find("thead "+h).prop("checked",!1),d=0;d tr[data-row-id="'+f[d][this.identifier]+'"]').removeClass(this.options.css.selected)._bgAria("selected","false").find(h).prop("checked",!1);this.element.trigger("deselected"+G,[f])}}return this},H.prototype.sort=function(b){var c=b?a.extend({},b):{};return c===this.sortDictionary?this:(this.sortDictionary=c,B.call(this),F.call(this),m.call(this),this)},H.prototype.getColumnSettings=function(){return a.merge([],this.columns)},H.prototype.getCurrentPage=function(){return this.current},H.prototype.getCurrentRows=function(){return a.merge([],this.currentRows)},H.prototype.getRowCount=function(){return this.rowCount},H.prototype.getSearchPhrase=function(){return this.searchPhrase},H.prototype.getSelectedRows=function(){return a.merge([],this.selectedRows)},H.prototype.getSortDictionary=function(){return a.extend({},this.sortDictionary)},H.prototype.getTotalPageCount=function(){return this.totalPages},H.prototype.getTotalRowCount=function(){return this.total},a.fn.extend({_bgAria:function(a,b){return b?this.attr("aria-"+a,b):this.attr("aria-"+a)},_bgBusyAria:function(a){return null==a||a?this._bgAria("busy","true"):this._bgAria("busy","false")},_bgRemoveAria:function(a){return this.removeAttr("aria-"+a)},_bgEnableAria:function(a){return null==a||a?this.removeClass("disabled")._bgAria("disabled","false"):this.addClass("disabled")._bgAria("disabled","true")},_bgEnableField:function(a){return null==a||a?this.removeAttr("disabled"):this.attr("disabled","disable")},_bgShowAria:function(a){return null==a||a?this.show()._bgAria("hidden","false"):this.hide()._bgAria("hidden","true")},_bgSelectAria:function(a){return null==a||a?this.addClass("active")._bgAria("selected","true"):this.removeClass("active")._bgAria("selected","false")},_bgId:function(a){return a?this.attr("id",a):this.attr("id")}}),!String.prototype.resolve){var I={checked:function(a){return"boolean"==typeof a?a?'checked="checked"':"":a}};String.prototype.resolve=function(b,c){var d=this;return a.each(b,function(b,e){if(null!=e&&"function"!=typeof e)if("object"==typeof e){var f=c?a.extend([],c):[];f.push(b),d=d.resolve(e,f)+""}else{I&&I[b]&&"function"==typeof I[b]&&(e=I[b](e)),b=c?c.join(".")+"."+b:b;var g=new RegExp("\\{\\{"+b+"\\}\\}","gm");d=d.replace(g,e.replace?e.replace(/\$/gi,"$"):e)}}),d}}Array.prototype.first||(Array.prototype.first=function(a){for(var b=0;bc?this.length>d?this.slice(c,d):this.slice(c):[]}),Array.prototype.where||(Array.prototype.where=function(a){for(var b=[],c=0;c tr").first(),d=!1;c.children().each(function(){var c=a(this),e=c.data(),f={id:e.columnId,identifier:null==b.identifier&&e.identifier||!1,converter:b.options.converters[e.converter||e.type]||b.options.converters.string,text:c.text(),align:e.align||"left",headerAlign:e.headerAlign||"left",cssClass:e.cssClass||"",headerCssClass:e.headerCssClass||"",formatter:b.options.formatters[e.formatter]||null,order:d||"asc"!==e.order&&"desc"!==e.order?null:e.order,searchable:!(e.searchable===!1),sortable:!(e.sortable===!1),visible:!(e.visible===!1),visibleInSelection:!(e.visibleInSelection===!1),width:a.isNumeric(e.width)?e.width+"px":"string"==typeof e.width?e.width:null};b.columns.push(f),null!=f.order&&(b.sortDictionary[f.id]=f.order),f.identifier&&(b.identifier=f.id,b.converter=f.converter),b.options.multiSort||null===f.order||(d=!0)})}function n(){function c(a){for(var b,c=new RegExp(e.searchPhrase,e.options.caseSensitive?"g":"gi"),d=0;d-1)return!0;return!1}function d(a,b){e.currentRows=a,p.call(e,b),e.options.keepSelection||(e.selectedRows=[]),y.call(e,a),t.call(e),v.call(e),e.element._bgBusyAria(!1).trigger("loaded"+H)}var e=this;if(this.element._bgBusyAria(!0).trigger("load"+H),F.call(this),this.options.ajax){var f=g.call(this),h=i.call(this);if(null==h||"string"!=typeof h||0===h.length)throw new Error("Url setting must be a none empty string or a function that returns one.");this.xqr&&this.xqr.abort();var j={url:h,data:f,success:function(b){e.xqr=null,"string"==typeof b&&(b=a.parseJSON(b)),b=e.options.responseHandler(b),e.current=b.current,d(b.rows,b.total)},error:function(a,b,c){e.xqr=null,"abort"!==b&&(u.call(e),e.element._bgBusyAria(!1).trigger("loaded"+H))}};j=a.extend(this.options.ajaxSettings,j),this.xqr=a.ajax(j)}else{var k=this.searchPhrase.length>0?this.rows.where(c):this.rows,l=k.length;-1!==this.rowCount&&(k=k.page(this.current,this.rowCount)),b.setTimeout(function(){d(k,l)},10)}}function o(){if(!this.options.ajax){var b=this,c=this.element.find("tbody > tr");c.each(function(){var c=a(this),e=c.children("td"),f={};a.each(b.columns,function(a,b){f[b.id]=b.converter.from(e.eq(a).text())}),d.call(b,f)}),p.call(this,this.rows.length),G.call(this)}}function p(a){this.total=a,this.totalPages=-1===this.rowCount?1:Math.ceil(this.total/this.rowCount)}function q(){var b=this.options.templates,c=this.element.parent().hasClass(this.options.css.responsiveTable)?this.element.parent():this.element;this.element.addClass(this.options.css.table),0===this.element.children("tbody").length&&this.element.append(b.body),1&this.options.navigation&&(this.header=a(b.header.resolve(f.call(this,{id:this.element._bgId()+"-header"}))),c.before(this.header)),2&this.options.navigation&&(this.footer=a(b.footer.resolve(f.call(this,{id:this.element._bgId()+"-footer"}))),c.after(this.footer))}function r(){if(0!==this.options.navigation){var b=this.options.css,c=h(b.actions),d=e.call(this,c);if(d.length>0){var g=this,i=this.options.templates,j=a(i.actions.resolve(f.call(this)));if(this.options.ajax){var k=i.icon.resolve(f.call(this,{iconCss:b.iconRefresh})),l=a(i.actionButton.resolve(f.call(this,{content:k,text:this.options.labels.refresh}))).on("click"+H,function(a){a.stopPropagation(),g.current=1,n.call(g)});j.append(l)}x.call(this,j),s.call(this,j),E.call(this,d,j)}}}function s(b){if(this.options.columnSelection&&this.columns.length>1){var c=this,d=this.options.css,e=this.options.templates,g=e.icon.resolve(f.call(this,{iconCss:d.iconColumns})),i=a(e.actionDropDown.resolve(f.call(this,{content:g}))),j=h(d.dropDownItem),k=h(d.dropDownItemCheckbox),m=h(d.dropDownMenuItems);a.each(this.columns,function(b,g){if(g.visibleInSelection){var o=a(e.actionDropDownCheckboxItem.resolve(f.call(c,{name:g.id,label:g.text,checked:g.visible}))).on("click"+H,j,function(b){b.stopPropagation();var d=a(this),e=d.find(k);if(!e.prop("disabled")){g.visible=e.prop("checked");var f=c.columns.where(l).length>1;d.parents(m).find(j+":has("+k+":checked)")._bgEnableAria(f).find(k)._bgEnableField(f),c.element.find("tbody").empty(),C.call(c),n.call(c)}});i.find(h(d.dropDownMenuItems)).append(o)}}),b.append(i)}}function t(){if(0!==this.options.navigation){var b=h(this.options.css.infos),c=e.call(this,b);if(c.length>0){var d=this.current*this.rowCount,g=a(this.options.templates.infos.resolve(f.call(this,{end:0===this.total||-1===d||d>this.total?this.total:d,start:0===this.total?0:d-this.rowCount+1,total:this.total})));E.call(this,c,g)}}}function u(){var a=this.element.children("tbody").first(),b=this.options.templates,c=this.columns.where(l).length;this.selection&&(c+=1),a.html(b.noResults.resolve(f.call(this,{columns:c})))}function v(){if(0!==this.options.navigation){var b=h(this.options.css.pagination),c=e.call(this,b)._bgShowAria(-1!==this.rowCount);if(-1!==this.rowCount&&c.length>0){var d=this.options.templates,g=this.current,i=this.totalPages,j=a(d.pagination.resolve(f.call(this))),k=i-g,l=-1*(this.options.padding-g),m=k>=this.options.padding?Math.max(l,1):Math.max(l-this.options.padding+k,1),n=2*this.options.padding+1,o=i>=n?n:i;w.call(this,j,"first","«","first")._bgEnableAria(g>1),w.call(this,j,"prev","<","prev")._bgEnableAria(g>1);for(var p=0;o>p;p++){var q=p+m;w.call(this,j,q,q,"page-"+q)._bgEnableAria()._bgSelectAria(q===g)}0===o&&w.call(this,j,1,1,"page-1")._bgEnableAria(!1)._bgSelectAria(),w.call(this,j,"next",">","next")._bgEnableAria(i>g),w.call(this,j,"last","»","last")._bgEnableAria(i>g),E.call(this,c,j)}}}function w(b,c,d,e){var g=this,i=this.options.templates,j=this.options.css,k=f.call(this,{css:e,text:d,page:c}),l=a(i.paginationItem.resolve(k)).on("click"+H,h(j.paginationButton),function(b){b.stopPropagation(),b.preventDefault();var c=a(this),d=c.parent();if(!d.hasClass("active")&&!d.hasClass("disabled")){var e={first:1,prev:g.current-1,next:g.current+1,last:g.totalPages},f=c.data("page");g.current=e[f]||f,n.call(g)}c.trigger("blur")});return b.append(l),l}function x(b){function c(a){return-1===a?d.options.labels.all:a}var d=this,e=this.options.rowCount;if(a.isArray(e)){var g=this.options.css,i=this.options.templates,j=a(i.actionDropDown.resolve(f.call(this,{content:c(this.rowCount)}))),k=h(g.dropDownMenu),l=h(g.dropDownMenuText),m=h(g.dropDownMenuItems),o=h(g.dropDownItemButton);a.each(e,function(b,e){var g=a(i.actionDropDownItem.resolve(f.call(d,{text:c(e),action:e})))._bgSelectAria(e===d.rowCount).on("click"+H,o,function(b){b.preventDefault();var e=a(this),f=e.data("action");f!==d.rowCount&&(d.current=1,d.rowCount=f,e.parents(m).children().each(function(){var b=a(this),c=b.find(o).data("action");b._bgSelectAria(c===f)}),e.parents(k).find(l).text(c(f)),n.call(d))});j.find(m).append(g)}),b.append(j)}}function y(b){if(b.length>0){var c=this,d=this.options.css,e=this.options.templates,g=this.element.children("tbody").first(),i=!0,j="";a.each(b,function(b,g){var h="",k=' data-row-id="'+(null==c.identifier?b:g[c.identifier])+'"',l="";if(c.selection){var m=-1!==a.inArray(g[c.identifier],c.selectedRows),n=e.select.resolve(f.call(c,{type:"checkbox",value:g[c.identifier],checked:m}));h+=e.cell.resolve(f.call(c,{content:n,css:d.selectCell})),i=i&&m,m&&(l+=d.selected,k+=' aria-selected="true"')}var o=null!=g.status&&c.options.statusMapping[g.status];o&&(l+=o),a.each(c.columns,function(b,i){if(i.visible){var j=a.isFunction(i.formatter)?i.formatter.call(c,i,g):i.converter.to(g[i.id]),k=i.cssClass.length>0?" "+i.cssClass:"";h+=e.cell.resolve(f.call(c,{content:null==j||""===j?" ":j,css:("right"===i.align?d.right:"center"===i.align?d.center:d.left)+k,style:null==i.width?"":"width:"+i.width+";"}))}}),l.length>0&&(k+=' class="'+l+'"'),j+=e.row.resolve(f.call(c,{attr:k,cells:h}))}),c.element.find("thead "+h(c.options.css.selectBox)).prop("checked",i),g.html(j),z.call(this,g)}else u.call(this)}function z(b){var c=this,d=h(this.options.css.selectBox);this.selection&&b.off("click"+H,d).on("click"+H,d,function(b){b.stopPropagation();var d=a(this),e=c.converter.from(d.val());d.prop("checked")?c.select([e]):c.deselect([e])}),b.off("click"+H,"> tr").on("click"+H,"> tr",function(b){b.stopPropagation();var d=a(this),e=null==c.identifier?d.data("row-id"):c.converter.from(d.data("row-id")+""),f=null==c.identifier?c.currentRows[e]:c.currentRows.first(function(a){return a[c.identifier]===e});c.selection&&c.options.rowSelect&&(d.hasClass(c.options.css.selected)?c.deselect([e]):c.select([e])),c.element.trigger("click"+H,[c.columns,f])})}function A(){if(0!==this.options.navigation){var c=this.options.css,d=h(c.search),g=e.call(this,d);if(g.length>0){var i=this,j=this.options.templates,k=null,l="",m=h(c.searchField),n=a(j.search.resolve(f.call(this))),o=n.is(m)?n:n.find(m);o.on("keyup"+H,function(c){c.stopPropagation();var d=a(this).val();(l!==d||13===c.which&&""!==d)&&(l=d,(13===c.which||0===d.length||d.length>=i.options.searchSettings.characters)&&(b.clearTimeout(k),k=b.setTimeout(function(){B.call(i,d)},i.options.searchSettings.delay)))}),E.call(this,g,n)}}}function B(a){this.searchPhrase!==a&&(this.current=1,this.searchPhrase=a,n.call(this))}function C(){var b=this,c=this.element.find("thead > tr"),d=this.options.css,e=this.options.templates,g="",i=this.options.sorting;if(this.selection){var j=this.options.multiSelect?e.select.resolve(f.call(b,{type:"checkbox",value:"all"})):"";g+=e.rawHeaderCell.resolve(f.call(b,{content:j,css:d.selectCell}))}if(a.each(this.columns,function(a,c){if(c.visible){var h=b.sortDictionary[c.id],j=i&&h&&"asc"===h?d.iconUp:i&&h&&"desc"===h?d.iconDown:"",k=e.icon.resolve(f.call(b,{iconCss:j})),l=c.headerAlign,m=c.headerCssClass.length>0?" "+c.headerCssClass:"";g+=e.headerCell.resolve(f.call(b,{column:c,icon:k,sortable:i&&c.sortable&&d.sortable||"",css:("right"===l?d.right:"center"===l?d.center:d.left)+m,style:null==c.width?"":"width:"+c.width+";"}))}}),c.html(g),i){var k=h(d.sortable);c.off("click"+H,k).on("click"+H,k,function(c){c.preventDefault(),D.call(b,a(this)),G.call(b),n.call(b)})}if(this.selection&&this.options.multiSelect){var l=h(d.selectBox);c.off("click"+H,l).on("click"+H,l,function(c){c.stopPropagation(),a(this).prop("checked")?b.select():b.deselect()})}}function D(a){var b=this.options.css,c=h(b.icon),d=a.data("column-id")||a.parents("th").first().data("column-id"),e=this.sortDictionary[d],f=a.find(c);if(this.options.multiSort||(a.parents("tr").first().find(c).removeClass(b.iconDown+" "+b.iconUp),this.sortDictionary={}),e&&"asc"===e)this.sortDictionary[d]="desc",f.removeClass(b.iconUp).addClass(b.iconDown);else if(e&&"desc"===e)if(this.options.multiSort){var g={};for(var i in this.sortDictionary)i!==d&&(g[i]=this.sortDictionary[i]);this.sortDictionary=g,f.removeClass(b.iconDown)}else this.sortDictionary[d]="asc",f.removeClass(b.iconDown).addClass(b.iconUp);else this.sortDictionary[d]="asc",f.addClass(b.iconUp)}function E(b,c){b.each(function(b,d){a(d).before(c.clone(!0)).remove()})}function F(){var a=this;b.setTimeout(function(){if("true"===a.element._bgAria("busy")){var b=a.options.templates,c=a.element.children("thead").first(),d=a.element.children("tbody").first(),e=d.find("tr > td").first(),g=a.element.height()-c.height()-(e.height()+20),h=a.columns.where(l).length;a.selection&&(h+=1),d.html(b.loading.resolve(f.call(a,{columns:h}))),-1!==a.rowCount&&g>0&&d.find("tr > td").css("padding","20px 0 "+g+"px")}},250)}function G(){function a(c,d,e){function f(a){return"asc"===h.order?a:-1*a}e=e||0;var g=e+1,h=b[e];return c[h.id]>d[h.id]?f(1):c[h.id]g?a(c,d,g):0}var b=[];if(!this.options.ajax){for(var c in this.sortDictionary)(this.options.multiSort||0===b.length)&&b.push({id:c,order:this.sortDictionary[c]});b.length>0&&this.rows.sort(a)}}var H=".rs.jquery.bootgrid",I=function(b,c){this.element=a(b),this.origin=this.element.clone(),this.options=a.extend(!0,{},I.defaults,this.element.data(),c);var d=this.options.rowCount=this.element.data().rowCount||c.rowCount||this.options.rowCount;this.columns=[],this.current=1,this.currentRows=[],this.identifier=null,this.selection=!1,this.converter=null,this.rowCount=a.isArray(d)?d[0]:d,this.rows=[],this.searchPhrase="",this.selectedRows=[],this.sortDictionary={},this.total=0,this.totalPages=0,this.cachedParams={lbl:this.options.labels,css:this.options.css,ctx:{}},this.header=null,this.footer=null,this.xqr=null};if(I.defaults={navigation:3,padding:2,columnSelection:!0,rowCount:[10,25,50,-1],selection:!1,multiSelect:!1,rowSelect:!1,keepSelection:!1,highlightRows:!1,sorting:!0,multiSort:!1,searchSettings:{delay:250,characters:1},ajax:!1,ajaxSettings:{method:"POST"},post:{},url:"",caseSensitive:!0,requestHandler:function(a){return a},responseHandler:function(a){return a},converters:{numeric:{from:function(a){return+a},to:function(a){return a+""}},string:{from:function(a){return a},to:function(a){return a}}},css:{actions:"actions btn-group",center:"text-center",columnHeaderAnchor:"column-header-anchor",columnHeaderText:"text",dropDownItem:"dropdown-item",dropDownItemButton:"dropdown-item-button",dropDownItemCheckbox:"dropdown-item-checkbox",dropDownMenu:"dropdown btn-group",dropDownMenuItems:"dropdown-menu pull-right",dropDownMenuText:"dropdown-text",footer:"bootgrid-footer container-fluid",header:"bootgrid-header container-fluid",icon:"icon glyphicon",iconColumns:"glyphicon-th-list",iconDown:"glyphicon-chevron-down",iconRefresh:"glyphicon-refresh",iconSearch:"glyphicon-search",iconUp:"glyphicon-chevron-up",infos:"infos",left:"text-left",pagination:"pagination",paginationButton:"button",responsiveTable:"table-responsive",right:"text-right",search:"search form-group",searchField:"search-field form-control",selectBox:"select-box",selectCell:"select-cell",selected:"active",sortable:"sortable",table:"bootgrid-table table"},formatters:{},labels:{all:"All",infos:"Showing {{ctx.start}} to {{ctx.end}} of {{ctx.total}} entries",loading:"Loading...",noResults:"No results found!",refresh:"Refresh",search:"Search"},statusMapping:{0:"success",1:"info",2:"warning",3:"danger"},templates:{actionButton:'{{ctx.content}} ',actionDropDown:'',actionDropDownItem:'{{ctx.text}} ',actionDropDownCheckboxItem:' {{ctx.label}} ',actions:'
',body:" ",cell:'{{ctx.content}} ',footer:'',header:'',headerCell:'{{ctx.column.text}} {{ctx.icon}} ',icon:' ',infos:'{{lbl.infos}}
',loading:'{{lbl.loading}} ',noResults:'{{lbl.noResults}} ',pagination:'',paginationItem:' ',rawHeaderCell:'{{ctx.content}} ',row:"{{ctx.cells}} ",search:'',select:' '}},I.prototype.append=function(a){if(this.options.ajax);else{for(var b=[],c=0;c0&&(this.options.multiSelect||1!==e.length);)if(c=b.pop(),-1===a.inArray(c,this.selectedRows))for(d=0;d0){var f=h(this.options.css.selectBox),g=this.selectedRows.length>=this.currentRows.length;for(d=0;!this.options.keepSelection&&g&&d tr "+f+":checked").trigger("click"+H),d=0;d tr[data-row-id="'+this.selectedRows[d]+'"]').addClass(this.options.css.selected)._bgAria("selected","true").find(f).prop("checked",!0);this.element.trigger("selected"+H,[e])}}return this},I.prototype.deselect=function(b){if(this.selection){b=b||this.currentRows.propValues(this.identifier);for(var c,d,e,f=[];b.length>0;)if(c=b.pop(),e=a.inArray(c,this.selectedRows),-1!==e)for(d=0;d0){var g=h(this.options.css.selectBox);for(this.element.find("thead "+g).prop("checked",!1),d=0;d tr[data-row-id="'+f[d][this.identifier]+'"]').removeClass(this.options.css.selected)._bgAria("selected","false").find(g).prop("checked",!1);this.element.trigger("deselected"+H,[f])}}return this},I.prototype.sort=function(b){var c=b?a.extend({},b):{};return c===this.sortDictionary?this:(this.sortDictionary=c,C.call(this),G.call(this),n.call(this),this)},I.prototype.getColumnSettings=function(){return a.merge([],this.columns)},I.prototype.getCurrentPage=function(){return this.current},I.prototype.getCurrentRows=function(){return a.merge([],this.currentRows)},I.prototype.getRowCount=function(){return this.rowCount},I.prototype.getSearchPhrase=function(){return this.searchPhrase},I.prototype.getSelectedRows=function(){return a.merge([],this.selectedRows)},I.prototype.getSortDictionary=function(){return a.extend({},this.sortDictionary)},I.prototype.getTotalPageCount=function(){return this.totalPages},I.prototype.getTotalRowCount=function(){return this.total},a.fn.extend({_bgAria:function(a,b){return b?this.attr("aria-"+a,b):this.attr("aria-"+a)},_bgBusyAria:function(a){return null==a||a?this._bgAria("busy","true"):this._bgAria("busy","false")},_bgRemoveAria:function(a){return this.removeAttr("aria-"+a)},_bgEnableAria:function(a){return null==a||a?this.removeClass("disabled")._bgAria("disabled","false"):this.addClass("disabled")._bgAria("disabled","true")},_bgEnableField:function(a){return null==a||a?this.removeAttr("disabled"):this.attr("disabled","disable")},_bgShowAria:function(a){return null==a||a?this.show()._bgAria("hidden","false"):this.hide()._bgAria("hidden","true")},_bgSelectAria:function(a){return null==a||a?this.addClass("active")._bgAria("selected","true"):this.removeClass("active")._bgAria("selected","false")},_bgId:function(a){return a?this.attr("id",a):this.attr("id")}}),!String.prototype.resolve){var J={checked:function(a){return"boolean"==typeof a?a?'checked="checked"':"":a}};String.prototype.resolve=function(b,c){var d=this;return a.each(b,function(b,e){if(null!=e&&"function"!=typeof e)if("object"==typeof e){var f=c?a.extend([],c):[];f.push(b),d=d.resolve(e,f)+""}else{J&&J[b]&&"function"==typeof J[b]&&(e=J[b](e)),b=c?c.join(".")+"."+b:b;var g=new RegExp("\\{\\{"+b+"\\}\\}","gm");d=d.replace(g,e.replace?e.replace(/\$/gi,"$"):e)}}),d}}Array.prototype.first||(Array.prototype.first=function(a){for(var b=0;bc?this.length>d?this.slice(c,d):this.slice(c):[]}),Array.prototype.where||(Array.prototype.where=function(a){for(var b=[],c=0;c 1;
- $this.parents(itemsSelector).find(selector + ":has(" + checkboxSelector + ":checked)")
- ._bgEnableAria(enable).find(checkboxSelector)._bgEnableField(enable);
-
- that.element.find("tbody").empty(); // Fixes an column visualization bug
- renderTableHeader.call(that);
- loadData.call(that);
- }
- });
- dropDown.find(getCssSelector(css.dropDownMenuItems)).append(item);
+ e.stopPropagation();
+
+ var $this = $(this),
+ checkbox = $this.find(checkboxSelector);
+ if (!checkbox.prop("disabled"))
+ {
+ column.visible = checkbox.prop("checked");
+ var enable = that.columns.where(isVisible).length > 1;
+ $this.parents(itemsSelector).find(selector + ":has(" + checkboxSelector + ":checked)")
+ ._bgEnableAria(enable).find(checkboxSelector)._bgEnableField(enable);
+
+ that.element.find("tbody").empty(); // Fixes an column visualization bug
+ renderTableHeader.call(that);
+ loadData.call(that);
+ }
+ });
+ dropDown.find(getCssSelector(css.dropDownMenuItems)).append(item);
+ }
});
actions.append(dropDown);
}
@@ -481,16 +485,17 @@ function renderPagination()
}
}
-function renderPaginationItem(list, uri, text, markerCss)
+function renderPaginationItem(list, page, text, markerCss)
{
var that = this,
tpl = this.options.templates,
css = this.options.css,
- values = getParams.call(this, { css: markerCss, text: text, uri: "#" + uri }),
+ values = getParams.call(this, { css: markerCss, text: text, page: page }),
item = $(tpl.paginationItem.resolve(values))
.on("click" + namespace, getCssSelector(css.paginationButton), function (e)
{
e.stopPropagation();
+ e.preventDefault();
var $this = $(this),
parent = $this.parent();
@@ -502,8 +507,8 @@ function renderPaginationItem(list, uri, text, markerCss)
next: that.current + 1,
last: that.totalPages
};
- var command = $this.attr("href").substr(1);
- that.current = commandList[command] || +command; // + converts string to int
+ var command = $this.data("page");
+ that.current = commandList[command] || command;
loadData.call(that);
}
$this.trigger("blur");
@@ -536,14 +541,14 @@ function renderRowCountSelection(actions)
$.each(rowCountList, function (index, value)
{
var item = $(tpl.actionDropDownItem.resolve(getParams.call(that,
- { text: getText(value), uri: "#" + value })))
+ { text: getText(value), action: value })))
._bgSelectAria(value === that.rowCount)
.on("click" + namespace, menuItemSelector, function (e)
{
e.preventDefault();
var $this = $(this),
- newRowCount = +$this.attr("href").substr(1);
+ newRowCount = $this.data("action");
if (newRowCount !== that.rowCount)
{
// todo: sophisticated solution needed for calculating which page is selected
@@ -552,7 +557,7 @@ function renderRowCountSelection(actions)
$this.parents(menuItemsSelector).children().each(function ()
{
var $item = $(this),
- currentRowCount = +$item.find(menuItemSelector).attr("href").substr(1);
+ currentRowCount = $item.find(menuItemSelector).data("action");
$item._bgSelectAria(currentRowCount === newRowCount);
});
$this.parents(menuSelector).find(menuTextSelector).text(getText(newRowCount));
diff --git a/src/public.js b/src/public.js
index 270d4b4..16c5c44 100644
--- a/src/public.js
+++ b/src/public.js
@@ -111,7 +111,7 @@ Grid.defaults = {
multiSort: false,
/**
- * Generall search settings to configure the search field behaviour.
+ * General search settings to configure the search field behaviour.
*
* @property searchSettings
* @type Object
@@ -152,7 +152,7 @@ Grid.defaults = {
/**
* Ajax request settings that shall be used for server-side communication.
- * All setting can be overridden except data, error, success and url.
+ * All setting except data, error, success and url can be overridden.
* For the full list of settings go to http://api.jquery.com/jQuery.ajax/.
*
* @property ajaxSettings
@@ -397,7 +397,7 @@ Grid.defaults = {
templates: {
actionButton: "{{ctx.content}} ",
actionDropDown: "",
- actionDropDownItem: "{{ctx.text}} ",
+ actionDropDownItem: "{{ctx.text}} ",
actionDropDownCheckboxItem: " {{ctx.label}} ",
actions: "
",
body: " ",
@@ -410,7 +410,7 @@ Grid.defaults = {
loading: "{{lbl.loading}} ",
noResults: "{{lbl.noResults}} ",
pagination: "",
- paginationItem: " ",
+ paginationItem: " ",
rawHeaderCell: "{{ctx.content}} ", // Used for the multi select box
row: "{{ctx.cells}} ",
search: "",
@@ -429,7 +429,7 @@ Grid.prototype.append = function(rows)
{
if (this.options.ajax)
{
- // todo: implement ajax DELETE
+ // todo: implement ajax PUT
}
else
{
@@ -736,6 +736,7 @@ Grid.prototype.sort = function(dictionary)
*
* @method getColumnSettings
* @return {Array} Returns a list of the column settings.
+ * @since 1.2.0
**/
Grid.prototype.getColumnSettings = function()
{
@@ -749,6 +750,7 @@ Grid.prototype.getColumnSettings = function()
*
* @method getCurrentPage
* @return {Number} Returns the current page index.
+ * @since 1.2.0
**/
Grid.prototype.getCurrentPage = function()
{
@@ -762,6 +764,7 @@ Grid.prototype.getCurrentPage = function()
*
* @method getCurrentPage
* @return {Array} Returns the current rows.
+ * @since 1.2.0
**/
Grid.prototype.getCurrentRows = function()
{
@@ -775,6 +778,7 @@ Grid.prototype.getCurrentRows = function()
*
* @method getRowCount
* @return {Number} Returns the row count per page.
+ * @since 1.2.0
**/
Grid.prototype.getRowCount = function()
{
@@ -788,6 +792,7 @@ Grid.prototype.getRowCount = function()
*
* @method getSearchPhrase
* @return {String} Returns the actual search phrase.
+ * @since 1.2.0
**/
Grid.prototype.getSearchPhrase = function()
{
@@ -801,6 +806,7 @@ Grid.prototype.getSearchPhrase = function()
*
* @method getSelectedRows
* @return {Array} Returns all selected rows.
+ * @since 1.2.0
**/
Grid.prototype.getSelectedRows = function()
{
@@ -814,6 +820,7 @@ Grid.prototype.getSelectedRows = function()
*
* @method getSortDictionary
* @return {Object} Returns the sort dictionary.
+ * @since 1.2.0
**/
Grid.prototype.getSortDictionary = function()
{
@@ -827,6 +834,7 @@ Grid.prototype.getSortDictionary = function()
*
* @method getTotalPageCount
* @return {Number} Returns the total page count.
+ * @since 1.2.0
**/
Grid.prototype.getTotalPageCount = function()
{
@@ -840,6 +848,7 @@ Grid.prototype.getTotalPageCount = function()
*
* @method getTotalRowCount
* @return {Number} Returns the total row count.
+ * @since 1.2.0
**/
Grid.prototype.getTotalRowCount = function()
{