angular-material-data-table
Advanced tools
Comparing version 0.10.3 to 0.10.4
{ | ||
"name": "angular-material-data-table", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"description": "Material Design data table.", | ||
@@ -5,0 +5,0 @@ "main": [ |
## Change Log | ||
#### Version 0.10.4 | ||
###### April 5, 2016 | ||
**Improvements** | ||
* Pagination is now usable on mobile. | ||
* More safeguards in pagination directive against performing calculations on `NaN`. | ||
**Bug Fixes** | ||
* Fixing issue where errors would be thrown if row selection was not enabled. | ||
#### Version 0.10.3 | ||
@@ -4,0 +16,0 @@ ###### April 1, 2016 |
@@ -5,3 +5,3 @@ /* | ||
* @license MIT | ||
* v0.10.3 | ||
* v0.10.4 | ||
*/ | ||
@@ -15,30 +15,39 @@ (function (window, angular, undefined) { | ||
$templateCache.put('md-table-pagination.html', | ||
'<span class="label" ng-if="$pagination.showPageSelect()">{{$pagination.label.page}}</span>\n' + | ||
'<div class="page-select" ng-if="$pagination.showPageSelect()">\n' + | ||
' <div class="label">{{$pagination.label.page}}</div>\n' + | ||
'\n' + | ||
'<md-select virtual-page-select total="{{$pagination.pages()}}" class="md-table-select" ng-if="$pagination.showPageSelect()" ng-model="$pagination.page" md-container-class="md-pagination-select" ng-change="$pagination.onPaginationChange()" ng-disabled="$pagination.disabled" aria-label="Page">\n' + | ||
' <md-content>\n' + | ||
' <md-option ng-repeat="page in $pageSelect.pages" ng-value="page">{{page}}</md-option>\n' + | ||
' </md-content>\n' + | ||
'</md-select>\n' + | ||
' <md-select virtual-page-select total="{{$pagination.pages()}}" class="md-table-select" ng-model="$pagination.page" md-container-class="md-pagination-select" ng-change="$pagination.onPaginationChange()" ng-disabled="$pagination.disabled" aria-label="Page">\n' + | ||
' <md-content>\n' + | ||
' <md-option ng-repeat="page in $pageSelect.pages" ng-value="page">{{page}}</md-option>\n' + | ||
' </md-content>\n' + | ||
' </md-select>\n' + | ||
'</div>\n' + | ||
'\n' + | ||
'<span class="label" ng-if="$pagination.limitOptions">{{$pagination.label.rowsPerPage}}</span>\n' + | ||
'<div class="limit-select" ng-if="$pagination.limitOptions">\n' + | ||
' <div class="label">{{$pagination.label.rowsPerPage}}</div>\n' + | ||
'\n' + | ||
'<md-select class="md-table-select" ng-if="$pagination.limitOptions" ng-model="$pagination.limit" md-container-class="md-pagination-select" ng-disabled="$pagination.disabled" aria-label="Rows" placeholder="{{ $pagination.limitOptions[0] }}">\n' + | ||
' <md-option ng-repeat="rows in $pagination.limitOptions" ng-value="rows">{{rows}}</md-option>\n' + | ||
'</md-select>\n' + | ||
' <md-select class="md-table-select" ng-model="$pagination.limit" md-container-class="md-pagination-select" ng-disabled="$pagination.disabled" aria-label="Rows" placeholder="{{ $pagination.limitOptions[0] }}">\n' + | ||
' <md-option ng-repeat="rows in $pagination.limitOptions" ng-value="rows">{{rows}}</md-option>\n' + | ||
' </md-select>\n' + | ||
'</div>\n' + | ||
'\n' + | ||
'<span class="label">{{$pagination.min()}} - {{$pagination.max()}} {{$pagination.label.of}} {{$pagination.total}}</span>\n' + | ||
'<div class="buttons">\n' + | ||
' <div class="label">{{$pagination.min()}} - {{$pagination.max()}} {{$pagination.label.of}} {{$pagination.total}}</div>\n' + | ||
'\n' + | ||
'<md-button class="md-icon-button" type="button" ng-if="$pagination.showBoundaryLinks()" ng-click="$pagination.first()" ng-disabled="$pagination.disabled || !$pagination.hasPrevious()" aria-label="First">\n' + | ||
' <md-icon md-svg-icon="navigate-first.svg"></md-icon>\n' + | ||
'</md-button>\n' + | ||
'<md-button class="md-icon-button" type="button" ng-click="$pagination.previous()" ng-disabled="$pagination.disabled || !$pagination.hasPrevious()" aria-label="Previous">\n' + | ||
' <md-icon md-svg-icon="navigate-before.svg"></md-icon>\n' + | ||
'</md-button>\n' + | ||
'<md-button class="md-icon-button" type="button" ng-click="$pagination.next()" ng-disabled="$pagination.disabled || $pagination.disableNext()" aria-label="Next">\n' + | ||
' <md-icon md-svg-icon="navigate-next.svg"></md-icon>\n' + | ||
'</md-button>\n' + | ||
'<md-button class="md-icon-button" type="button" ng-if="$pagination.showBoundaryLinks()" ng-click="$pagination.last()" ng-disabled="$pagination.disabled || $pagination.disableNext()" aria-label="Last">\n' + | ||
' <md-icon md-svg-icon="navigate-last.svg"></md-icon>\n' + | ||
'</md-button>'); | ||
' <md-button class="md-icon-button" type="button" ng-if="$pagination.showBoundaryLinks()" ng-click="$pagination.first()" ng-disabled="$pagination.disabled || !$pagination.hasPrevious()" aria-label="First">\n' + | ||
' <md-icon md-svg-icon="navigate-first.svg"></md-icon>\n' + | ||
' </md-button>\n' + | ||
'\n' + | ||
' <md-button class="md-icon-button" type="button" ng-click="$pagination.previous()" ng-disabled="$pagination.disabled || !$pagination.hasPrevious()" aria-label="Previous">\n' + | ||
' <md-icon md-svg-icon="navigate-before.svg"></md-icon>\n' + | ||
' </md-button>\n' + | ||
'\n' + | ||
' <md-button class="md-icon-button" type="button" ng-click="$pagination.next()" ng-disabled="$pagination.disabled || $pagination.disableNext()" aria-label="Next">\n' + | ||
' <md-icon md-svg-icon="navigate-next.svg"></md-icon>\n' + | ||
' </md-button>\n' + | ||
'\n' + | ||
' <md-button class="md-icon-button" type="button" ng-if="$pagination.showBoundaryLinks()" ng-click="$pagination.last()" ng-disabled="$pagination.disabled || $pagination.disableNext()" aria-label="Last">\n' + | ||
' <md-icon md-svg-icon="navigate-last.svg"></md-icon>\n' + | ||
' </md-button>\n' + | ||
'</div>'); | ||
}]); | ||
@@ -878,8 +887,8 @@ | ||
function mdSelect($compile, $parse) { | ||
// empty controller to bind scope properties to | ||
function Controller() { | ||
} | ||
function postLink(scope, element, attrs, ctrls) { | ||
@@ -889,9 +898,9 @@ var self = ctrls.shift(); | ||
var getId = $parse(attrs.mdSelectId); | ||
self.id = getId(self.model); | ||
if(self.id) { | ||
if(tableCtrl.$$rowSelect && self.id) { | ||
if(tableCtrl.$$hash.has(self.id)) { | ||
var index = tableCtrl.selected.indexOf(tableCtrl.$$hash.get(self.id)); | ||
// if the item is no longer selected remove it | ||
@@ -901,3 +910,3 @@ if(index === -1) { | ||
} | ||
// if the item is not a reference to the current model update the reference | ||
@@ -908,5 +917,5 @@ else if(!tableCtrl.$$hash.equals(self.id, self.model)) { | ||
} | ||
} else { | ||
// check if the item has been selected | ||
@@ -917,3 +926,3 @@ tableCtrl.selected.some(function (item, index) { | ||
tableCtrl.selected.splice(index, 1, self.model); | ||
return true; | ||
@@ -924,3 +933,3 @@ } | ||
} | ||
self.isSelected = function () { | ||
@@ -930,10 +939,10 @@ if(!tableCtrl.$$rowSelect) { | ||
} | ||
if(self.id) { | ||
return tableCtrl.$$hash.has(self.id); | ||
} | ||
return tableCtrl.selected.indexOf(self.model) !== -1; | ||
}; | ||
self.select = function () { | ||
@@ -943,3 +952,3 @@ if(self.disabled) { | ||
} | ||
if(tableCtrl.enableMultiSelect()) { | ||
@@ -950,3 +959,3 @@ tableCtrl.selected.push(self.model); | ||
} | ||
if(angular.isFunction(self.onSelect)) { | ||
@@ -956,3 +965,3 @@ self.onSelect(self.model); | ||
}; | ||
self.deselect = function () { | ||
@@ -962,5 +971,5 @@ if(self.disabled) { | ||
} | ||
tableCtrl.selected.splice(tableCtrl.selected.indexOf(self.model), 1); | ||
if(angular.isFunction(self.onDeselect)) { | ||
@@ -970,3 +979,3 @@ self.onDeselect(self.model); | ||
}; | ||
self.toggle = function (event) { | ||
@@ -976,10 +985,10 @@ if(event && event.stopPropagation) { | ||
} | ||
return self.isSelected() ? self.deselect() : self.select(); | ||
}; | ||
function autoSelect() { | ||
return attrs.mdAutoSelect === '' || self.autoSelect; | ||
} | ||
function createCheckbox() { | ||
@@ -992,6 +1001,6 @@ var checkbox = angular.element('<md-checkbox>').attr({ | ||
}); | ||
return angular.element('<td class="md-cell md-checkbox-cell">').append($compile(checkbox)(scope)); | ||
} | ||
function disableSelection() { | ||
@@ -1001,3 +1010,3 @@ Array.prototype.some.call(element.children(), function (child) { | ||
}); | ||
if(autoSelect()) { | ||
@@ -1007,6 +1016,6 @@ element.off('click', toggle); | ||
} | ||
function enableSelection() { | ||
element.prepend(createCheckbox()); | ||
if(autoSelect()) { | ||
@@ -1016,7 +1025,7 @@ element.on('click', toggle); | ||
} | ||
function enableRowSelection() { | ||
return tableCtrl.$$rowSelect; | ||
} | ||
function onSelectChange(selected) { | ||
@@ -1026,3 +1035,3 @@ if(!self.id) { | ||
} | ||
if(tableCtrl.$$hash.has(self.id)) { | ||
@@ -1033,6 +1042,6 @@ // check if the item has been deselected | ||
} | ||
return; | ||
} | ||
// check if the item has been selected | ||
@@ -1043,3 +1052,3 @@ if(selected.indexOf(self.model) !== -1) { | ||
} | ||
function toggle(event) { | ||
@@ -1050,3 +1059,3 @@ scope.$applyAsync(function () { | ||
} | ||
scope.$watch(enableRowSelection, function (enable) { | ||
@@ -1059,3 +1068,3 @@ if(enable) { | ||
}); | ||
scope.$watch(autoSelect, function (newValue, oldValue) { | ||
@@ -1065,3 +1074,3 @@ if(newValue === oldValue) { | ||
} | ||
if(tableCtrl.$$rowSelect && newValue) { | ||
@@ -1073,9 +1082,9 @@ element.on('click', toggle); | ||
}); | ||
scope.$watch(self.isSelected, function (isSelected) { | ||
return isSelected ? element.addClass('md-selected') : element.removeClass('md-selected'); | ||
}); | ||
scope.$watch(tableCtrl.enableMultiSelect, function (multiple) { | ||
if(!multiple) { | ||
if(tableCtrl.$$rowSelect && !multiple) { | ||
// remove all but the first selected item | ||
@@ -1085,5 +1094,5 @@ tableCtrl.selected.splice(1); | ||
}); | ||
tableCtrl.registerModelChangeListener(onSelectChange); | ||
element.on('$destroy', function () { | ||
@@ -1093,3 +1102,3 @@ tableCtrl.removeModelChangeListener(onSelectChange); | ||
} | ||
return { | ||
@@ -1316,4 +1325,8 @@ bindToController: true, | ||
function isPositive(number) { | ||
return !isNaN(number) && !isZero(number); | ||
} | ||
function isZero(number) { | ||
return number === 0 || number === '0'; | ||
return parseInt(number, 10) === 0; | ||
} | ||
@@ -1365,3 +1378,3 @@ | ||
self.pages = function () { | ||
return Math.ceil(self.total / (isZero(self.limit) ? 1 : self.limit)); | ||
return isPositive(self.total) ? Math.ceil(self.total / (isPositive(self.limit) ? 1 : self.limit)) : 1; | ||
}; | ||
@@ -1383,3 +1396,3 @@ | ||
$scope.$watch('$pagination.limit', function (newValue, oldValue) { | ||
if(newValue === oldValue) { | ||
if(isNaN(newValue) || isNaN(oldValue) || newValue === oldValue) { | ||
return; | ||
@@ -1398,3 +1411,3 @@ } | ||
$scope.$watch('$pagination.total', function (newValue, oldValue) { | ||
if(newValue === oldValue) { | ||
if(isNaN(newValue) || newValue === oldValue) { | ||
return; | ||
@@ -1401,0 +1414,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(a,b,c){"use strict";function d(){function a(a){a.addClass("md-body")}return{compile:a,restrict:"A"}}function e(){function a(a){var b=a.find("md-select");return b.length&&b.addClass("md-table-select").attr("md-container-class","md-table-select"),a.addClass("md-cell"),c}function b(){}function c(a,b,c,d){function e(){return i.$$columns[f()]}function f(){return Array.prototype.indexOf.call(b.parent().children(),b[0])}var g=b.find("md-select"),h=d.shift(),i=d.shift();c.ngClick&&b.addClass("md-clickable"),g.length&&(g.on("click",function(a){a.stopPropagation()}),b.addClass("md-clickable").on("click",function(a){a.stopPropagation(),g[0].click()})),h.getTable=i.getElement,a.$watch(e,function(a){a&&(a.numeric?b.addClass("md-numeric"):b.removeClass("md-numeric"))})}return{controller:b,compile:a,require:["mdCell","^^mdTable"],restrict:"A"}}function f(a,c){function d(a){return a.addClass("md-column"),e}function e(d,e,f,g){function h(){var c=b.element('<md-icon md-svg-icon="arrow-up.svg">');a(c.addClass("md-sort-icon").attr("ng-class","getDirection()"))(d),e.hasClass("md-numeric")?e.prepend(c):e.append(c)}function i(){Array.prototype.some.call(e.find("md-icon"),function(a){return a.classList.contains("md-sort-icon")&&e[0].removeChild(a)})}function j(){i(),e.removeClass("md-sort").off("click",o)}function k(){h(),e.addClass("md-sort").on("click",o)}function l(){return Array.prototype.indexOf.call(e.parent().children(),e[0])}function m(){return d.orderBy&&(q.order===d.orderBy||q.order==="-"+d.orderBy)}function n(){return""===f.mdNumeric||d.numeric}function o(){d.$applyAsync(function(){m()?q.order="md-asc"===d.getDirection()?"-"+d.orderBy:d.orderBy:q.order="md-asc"===d.getDirection()?d.orderBy:"-"+d.orderBy,b.isFunction(q.onReorder)&&c.nextTick(function(){q.onReorder(q.order)})})}function p(a,b){r.$$columns[a]=b,b.numeric?e.addClass("md-numeric"):e.removeClass("md-numeric")}var q=g.shift(),r=g.shift();d.getDirection=function(){return m()?"-"===q.order.charAt(0)?"md-desc":"md-asc":""===f.mdDesc||d.$eval(f.mdDesc)?"md-desc":"md-asc"},d.$watch(m,function(a){a?e.addClass("md-active"):e.removeClass("md-active")}),d.$watch(l,function(a){p(a,{numeric:n()})}),d.$watch(n,function(a){p(l(),{numeric:a})}),d.$watch("orderBy",function(a){a?k():j()})}return{compile:d,require:["^^mdHead","^^mdTable"],restrict:"A",scope:{numeric:"=?mdNumeric",orderBy:"@?mdOrderBy"}}}function g(a){return function(c,d,e,f){if(e&&"object"==typeof e){var g=a(c,d,!0,f);return b.extend(g.instance,e),g()}return a(c,d,e,f)}}function h(a,c,d,e,f,g,h,i,j){function k(c,d){var f,h=g.$new(),i=a(c)(h),j=e.createBackdrop(h,"md-edit-dialog-backdrop");return d.controller?f=m(d,h,{$element:i,$scope:h}):b.extend(h,d.scope),d.disableScroll&&l(i),v.prepend(j).append(i.addClass("md-whiteframe-1dp")),r(i,d.target),d.focusOnOpen&&q(i),d.clickOutsideToClose&&j.on("click",function(){i.remove()}),d.escToClose&&p(i),i.on("$destroy",function(){u=!1,j.remove()}),f}function l(a){var b=e.disableScrollAround(a,v);a.on("$destroy",function(){b()})}function m(a,d,e){return a.controller?(a.resolve&&b.extend(e,a.resolve),a.locals&&b.extend(e,a.locals),a.controllerAs?(d[a.controllerAs]={},a.bindToController?b.extend(d[a.controllerAs],a.scope):b.extend(d,a.scope)):b.extend(d,a.scope),a.bindToController?c(a.controller,e,d[a.controllerAs]):c(a.controller,e)):void 0}function n(a){return f(function(c,d){function e(a){d("Unexpected template value. Expected a string; received a "+a+".")}var f=a.template;if(f)return b.isString(f)?c(f):e(typeof f);if(a.templateUrl){if(f=h.get(a.templateUrl))return c(f);var g=function(a){return c(a)},j=function(){return d("Error retrieving template from URL.")};return i(a.templateUrl).then(g,j)}d("Template not provided.")})}function o(a){u=!1,console.error(a)}function p(a){var b=function(b){b.keyCode===t&&a.remove()};v.on("keyup",b),a.on("$destroy",function(){v.off("keyup",b)})}function q(a){e.nextTick(function(){var b=e.findFocusTarget(a);b&&b.focus()},!1)}function r(a,c){var d=b.element(c).controller("mdCell").getTable(),e=function(){return a.prop("clientHeight")},f=function(){return{width:i(),height:e()}},h=function(){var a=d.parent();return"MD-TABLE-CONTAINER"===a.prop("tagName")?a[0].getBoundingClientRect():d[0].getBoundingClientRect()},i=function(){return a.prop("clientWidth")},k=function(){var b=f(),d=c.getBoundingClientRect(),e=h();b.width>e.right-d.left?a.css("left",e.right-b.width+"px"):a.css("left",d.left+"px"),b.height>e.bottom-d.top?a.css("top",e.bottom-b.height+"px"):a.css("top",d.top+1+"px"),a.css("minWidth",d.width+"px")},l=g.$watch(i,k),m=g.$watch(e,k);j.addEventListener("resize",k),a.on("$destroy",function(){l(),m(),j.removeEventListener("resize",k)})}function s(a,c){function d(){var a='type="'+(c.type||"text")+'"';for(var b in c.validators)a+=" "+b+'="'+c.validators[b]+'"';return a}return{controller:["$element","$q","save","$scope",function(a,c,d,e){function f(){return e.editDialog.$invalid?c.reject():b.isFunction(d)?c.when(d(e.editDialog.input)):c.resolve()}this.dismiss=function(){a.remove()},this.getInput=function(){return e.editDialog.input},e.dismiss=this.dismiss,e.submit=function(){f().then(function(){e.dismiss()})}}],locals:{save:c.save},scope:{cancel:c.cancel||"Cancel",messages:c.messages,model:c.modelValue,ok:c.ok||"Save",placeholder:c.placeholder,title:c.title,size:a},template:'<md-edit-dialog><div layout="column" class="md-content"><div ng-if="size === \'large\'" class="md-title">{{title || \'Edit\'}}</div><form name="editDialog" layout="column" ng-submit="submit(model)"><md-input-container md-no-float><input name="input" ng-model="model" md-autofocus placeholder="{{placeholder}} "'+d()+'><div ng-messages="editDialog.input.$error"><div ng-repeat="(key, message) in messages" ng-message="{{key}}">{{message}}</div></div></md-input-container></form></div><div ng-if="size === \'large\'" layout="row" layout-align="end" class="md-actions"><md-button class="md-primary" ng-click="dismiss()">{{cancel}}</md-button><md-button class="md-primary" ng-click="submit()">{{ok}}</md-button></div></md-edit-dialog>'}}var t=27,u=!1,v=b.element(d.prop("body")),w={clickOutsideToClose:!0,disableScroll:!0,escToClose:!0,focusOnOpen:!0};return this.show=function(a){if(u)return f.reject();if(u=!0,a=b.extend({},w,a),!a.targetEvent)return o("options.targetEvent is required to align the dialog with the table cell.");if(!a.targetEvent.currentTarget.classList.contains("md-cell"))return o("The event target must be a table cell.");if(a.bindToController&&!a.controllerAs)return o("You must define options.controllerAs when options.bindToController is true.");a.target=a.targetEvent.currentTarget;var c=n(a),d=[c];for(var e in a.resolve)c=a.resolve[e],d.push(f.when(b.isFunction(c)?c():c));return c=f.all(d),c["catch"](o),c.then(function(b){var c=b.shift();for(var d in a.resolve)a.resolve[d]=b.shift();return k(c,a)})},this.small=function(a){return this.show(b.extend({},a,s("small",a)))}.bind(this),this.large=function(a){return this.show(b.extend({},a,s("large",a)))}.bind(this),this}function i(){function a(a){a.addClass("md-foot")}return{compile:a,restrict:"A"}}function j(a){function c(a){return a.addClass("md-head"),e}function d(){}function e(c,d,e,f){function g(){d.children().prepend('<th class="md-column md-checkbox-column">')}function h(){d.prop("lastElementChild").firstElementChild.appendChild(a(i())(c)[0])}function i(){return b.element("<md-checkbox>").attr({"aria-label":"Select All","ng-click":"toggleAll()","ng-checked":"allSelected()","ng-disabled":"!getSelectableRows().length"})}function j(){var a=d.prop("lastElementChild").firstElementChild;a.classList.contains("md-checkbox-column")&&b.element(a).empty()}function k(){return f.$$rowSelect}function l(a){return b.element(a).controller("mdSelect")}function m(){Array.prototype.some.call(d.find("th"),function(a){return a.classList.contains("md-checkbox-column")&&a.remove()})}var n=new Array(2);c.allSelected=function(){var a=c.getSelectableRows();return a.length&&a.every(function(a){return a.isSelected()})},c.getSelectableRows=function(){return f.getBodyRows().map(l).filter(function(a){return a&&!a.disabled})},c.selectAll=function(){f.getBodyRows().map(l).forEach(function(a){a&&!a.isSelected()&&a.select()})},c.toggleAll=function(){return c.allSelected()?c.unSelectAll():c.selectAll()},c.unSelectAll=function(){f.getBodyRows().map(l).forEach(function(a){a&&a.isSelected()&&a.deselect()})},c.$watchGroup([k,f.enableMultiSelect],function(a){a[0]!==n[0]?a[0]?(g(),a[1]&&h()):m():a[0]&&a[1]!==n[1]&&(a[1]?h():j()),b.copy(a,n)})}return{bindToController:!0,compile:c,controller:d,controllerAs:"$mdHead",require:"^^mdTable",restrict:"A",scope:{order:"=?mdOrder",onReorder:"=?mdOnReorder"}}}function k(){function a(a){return a.addClass("md-row"),c}function c(a,c,d,e){function f(){return e.$$rowSelect}function g(){return-1!==e.getBodyRows().indexOf(c[0])}function h(a){return c[0].contains(a[0])}if(g()){var i=b.element('<td class="md-cell">');a.$watch(f,function(a){return a&&!d.mdSelect?void(h(i)||c.prepend(i)):void(h(i)&&i.remove())})}}return{compile:a,require:"^^mdTable",restrict:"A"}}function l(a,c){function d(){}function e(d,e,f,g){function h(){return""===f.mdAutoSelect||o.autoSelect}function i(){var c=b.element("<md-checkbox>").attr({"aria-label":"Select Row","ng-click":"$mdSelect.toggle($event)","ng-checked":"$mdSelect.isSelected()","ng-disabled":"$mdSelect.disabled"});return b.element('<td class="md-cell md-checkbox-cell">').append(a(c)(d))}function j(){Array.prototype.some.call(e.children(),function(a){return a.classList.contains("md-checkbox-cell")&&e[0].removeChild(a)}),h()&&e.off("click",n)}function k(){e.prepend(i()),h()&&e.on("click",n)}function l(){return p.$$rowSelect}function m(a){return o.id?p.$$hash.has(o.id)?void(-1===a.indexOf(p.$$hash.get(o.id))&&p.$$hash.purge(o.id)):void(-1!==a.indexOf(o.model)&&p.$$hash.update(o.id,o.model)):void 0}function n(a){d.$applyAsync(function(){o.toggle(a)})}var o=g.shift(),p=g.shift(),q=c(f.mdSelectId);if(o.id=q(o.model),o.id)if(p.$$hash.has(o.id)){var r=p.selected.indexOf(p.$$hash.get(o.id));-1===r?p.$$hash.purge(o.id):p.$$hash.equals(o.id,o.model)||(p.$$hash.update(o.id,o.model),p.selected.splice(r,1,o.model))}else p.selected.some(function(a,b){return q(a)===o.id?(p.$$hash.update(o.id,o.model),p.selected.splice(b,1,o.model),!0):void 0});o.isSelected=function(){return p.$$rowSelect?o.id?p.$$hash.has(o.id):-1!==p.selected.indexOf(o.model):!1},o.select=function(){o.disabled||(p.enableMultiSelect()?p.selected.push(o.model):p.selected.splice(0,p.selected.length,o.model),b.isFunction(o.onSelect)&&o.onSelect(o.model))},o.deselect=function(){o.disabled||(p.selected.splice(p.selected.indexOf(o.model),1),b.isFunction(o.onDeselect)&&o.onDeselect(o.model))},o.toggle=function(a){return a&&a.stopPropagation&&a.stopPropagation(),o.isSelected()?o.deselect():o.select()},d.$watch(l,function(a){a?k():j()}),d.$watch(h,function(a,b){a!==b&&(p.$$rowSelect&&a?e.on("click",n):e.off("click",n))}),d.$watch(o.isSelected,function(a){return a?e.addClass("md-selected"):e.removeClass("md-selected")}),d.$watch(p.enableMultiSelect,function(a){a||p.selected.splice(1)}),p.registerModelChangeListener(m),e.on("$destroy",function(){p.removeModelChangeListener(m)})}return{bindToController:!0,controller:d,controllerAs:"$mdSelect",link:e,require:["mdSelect","^^mdTable"],restrict:"A",scope:{model:"=mdSelect",disabled:"=ngDisabled",onSelect:"=?mdOnSelect",onDeselect:"=?mdOnDeselect",autoSelect:"=mdAutoSelect"}}}function m(){var a={};this.equals=function(b,c){return a[b]===c},this.get=function(b){return a[b]},this.has=function(b){return a.hasOwnProperty(b)},this.purge=function(b){delete a[b]},this.update=function(b,c){a[b]=c}}function n(){function a(a,c){if(a.addClass("md-table"),c.hasOwnProperty("mdProgress")){var d=a.find("tbody")[0],e=b.element('<thead class="md-table-progress">');d&&a[0].insertBefore(e[0],d)}}function c(a,c,d,e){function f(){l.$$rowSelect=!0,k=e.$watchCollection("$mdTable.selected",function(a){o.forEach(function(b){b(a)})}),c.addClass("md-row-select")}function g(){l.$$rowSelect=!1,b.isFunction(k)&&k(),c.removeClass("md-row-select")}function h(){return n.length?void n[0]["finally"](function(){n.shift(),h()}):e.$applyAsync()}function i(){return""===a.mdRowSelect||l.rowSelect}function j(){return l.selected?b.isArray(l.selected)?!0:console.error("Row selection: Expected an array. Recived "+typeof l.selected+"."):console.error("Row selection: ngModel is not defined.")}var k,l=this,n=[],o=[];l.$$hash=new m,l.$$columns={},l.columnCount=function(){return l.getRows(c[0]).reduce(function(a,b){return b.cells.length>a?b.cells.length:a},0)},l.getRows=function(a){return Array.prototype.filter.call(a.rows,function(a){return!a.classList.contains("ng-leave")})},l.getBodyRows=function(){return Array.prototype.reduce.call(c.prop("tBodies"),function(a,b){return a.concat(l.getRows(b))},[])},l.getElement=function(){return c},l.getHeaderRows=function(){return l.getRows(c.prop("tHead"))},l.enableMultiSelect=function(){return""===a.multiple||e.$eval(a.multiple)},l.waitingOnPromise=function(){return!!n.length},l.queuePromise=function(a){a&&1===n.push(b.isArray(a)?d.all(a):d.when(a))&&h()},l.registerModelChangeListener=function(a){o.push(a)},l.removeModelChangeListener=function(a){var b=o.indexOf(a);-1!==b&&o.splice(b,1)},a.hasOwnProperty("mdProgress")&&e.$watch("$mdTable.progress",l.queuePromise),e.$watch(i,function(a){a&&j()?f():g()})}return c.$inject=["$attrs","$element","$q","$scope"],{bindToController:!0,compile:a,controller:c,controllerAs:"$mdTable",restrict:"A",scope:{progress:"=?mdProgress",selected:"=ngModel",rowSelect:"=mdRowSelect"}}}function o(){function a(a){a.addClass("md-table-pagination")}function c(a,c,d){function e(a){return 0===a||"0"===a}var f=this,g={page:"Page:",rowsPerPage:"Rows per page:",of:"of"};f.label=b.copy(g),f.disableNext=function(){return e(f.limit)||!f.hasNext()},f.first=function(){f.page=1,f.onPaginationChange()},f.hasNext=function(){return f.page*f.limit<f.total},f.hasPrevious=function(){return f.page>1},f.last=function(){f.page=f.pages(),f.onPaginationChange()},f.max=function(){return f.hasNext()?f.page*f.limit:f.total},f.min=function(){return e(f.total)?0:f.page*f.limit-f.limit+1},f.next=function(){f.page++,f.onPaginationChange()},f.onPaginationChange=function(){b.isFunction(f.onPaginate)&&c.nextTick(function(){f.onPaginate(f.page,f.limit)})},f.pages=function(){return Math.ceil(f.total/(e(f.limit)?1:f.limit))},f.previous=function(){f.page--,f.onPaginationChange()},f.showBoundaryLinks=function(){return""===a.mdBoundaryLinks||f.boundaryLinks},f.showPageSelect=function(){return""===a.mdPageSelect||f.pageSelect},d.$watch("$pagination.limit",function(a,b){a!==b&&(f.page=Math.floor((f.page*b-b+a)/(e(a)?1:a)),f.onPaginationChange())}),a.$observe("mdLabel",function(a){b.extend(f.label,g,d.$eval(a))}),d.$watch("$pagination.total",function(a,b){a!==b&&f.page>f.pages()&&f.last()})}return c.$inject=["$attrs","$mdUtil","$scope"],{bindToController:{boundaryLinks:"=?mdBoundaryLinks",disabled:"=ngDisabled",limit:"=mdLimit",page:"=mdPage",pageSelect:"=?mdPageSelect",onPaginate:"=?mdOnPaginate",limitOptions:"=?mdLimitOptions",total:"@mdTotal"},compile:a,controller:c,controllerAs:"$pagination",restrict:"E",scope:{},templateUrl:"md-table-pagination.html"}}function p(){function a(a,b,c,d){a.columnCount=d.columnCount,a.deferred=d.waitingOnPromise}return{link:a,require:"^^mdTable",restrict:"C",scope:{},templateUrl:"md-table-progress.html"}}function q(){function a(a,b){function c(a,b){return Math.min(a,isFinite(b)&&d(b)?b:1)}function d(a){return a>0}function e(a){if(f.pages.length>a)return f.pages.splice(a);for(var b=f.pages.length;a>b;b++)f.pages.push(b+1)}var f=this,g=a.find("md-content");f.pages=[],g.on("scroll",function(){g.prop("clientHeight")+g.prop("scrollTop")>=g.prop("scrollHeight")&&b.$applyAsync(function(){e(c(f.pages.length+10,f.total))})}),b.$watch("$pageSelect.total",function(a){e(c(Math.max(f.pages.length,10),a))})}return a.$inject=["$element","$scope"],{bindToController:{total:"@"},controller:a,controllerAs:"$pageSelect"}}b.module("md.table.templates",["md-table-pagination.html","md-table-progress.html","arrow-up.svg","navigate-before.svg","navigate-first.svg","navigate-last.svg","navigate-next.svg"]),b.module("md-table-pagination.html",[]).run(["$templateCache",function(a){a.put("md-table-pagination.html",'<span class="label" ng-if="$pagination.showPageSelect()">{{$pagination.label.page}}</span>\n\n<md-select virtual-page-select total="{{$pagination.pages()}}" class="md-table-select" ng-if="$pagination.showPageSelect()" ng-model="$pagination.page" md-container-class="md-pagination-select" ng-change="$pagination.onPaginationChange()" ng-disabled="$pagination.disabled" aria-label="Page">\n <md-content>\n <md-option ng-repeat="page in $pageSelect.pages" ng-value="page">{{page}}</md-option>\n </md-content>\n</md-select>\n\n<span class="label" ng-if="$pagination.limitOptions">{{$pagination.label.rowsPerPage}}</span>\n\n<md-select class="md-table-select" ng-if="$pagination.limitOptions" ng-model="$pagination.limit" md-container-class="md-pagination-select" ng-disabled="$pagination.disabled" aria-label="Rows" placeholder="{{ $pagination.limitOptions[0] }}">\n <md-option ng-repeat="rows in $pagination.limitOptions" ng-value="rows">{{rows}}</md-option>\n</md-select>\n\n<span class="label">{{$pagination.min()}} - {{$pagination.max()}} {{$pagination.label.of}} {{$pagination.total}}</span>\n\n<md-button class="md-icon-button" type="button" ng-if="$pagination.showBoundaryLinks()" ng-click="$pagination.first()" ng-disabled="$pagination.disabled || !$pagination.hasPrevious()" aria-label="First">\n <md-icon md-svg-icon="navigate-first.svg"></md-icon>\n</md-button>\n<md-button class="md-icon-button" type="button" ng-click="$pagination.previous()" ng-disabled="$pagination.disabled || !$pagination.hasPrevious()" aria-label="Previous">\n <md-icon md-svg-icon="navigate-before.svg"></md-icon>\n</md-button>\n<md-button class="md-icon-button" type="button" ng-click="$pagination.next()" ng-disabled="$pagination.disabled || $pagination.disableNext()" aria-label="Next">\n <md-icon md-svg-icon="navigate-next.svg"></md-icon>\n</md-button>\n<md-button class="md-icon-button" type="button" ng-if="$pagination.showBoundaryLinks()" ng-click="$pagination.last()" ng-disabled="$pagination.disabled || $pagination.disableNext()" aria-label="Last">\n <md-icon md-svg-icon="navigate-last.svg"></md-icon>\n</md-button>')}]),b.module("md-table-progress.html",[]).run(["$templateCache",function(a){a.put("md-table-progress.html",'<tr>\n <th colspan="{{columnCount()}}">\n <md-progress-linear ng-show="deferred()" md-mode="indeterminate"></md-progress-linear>\n </th>\n</tr>')}]),b.module("arrow-up.svg",[]).run(["$templateCache",function(a){a.put("arrow-up.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg>')}]),b.module("navigate-before.svg",[]).run(["$templateCache",function(a){a.put("navigate-before.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>')}]),b.module("navigate-first.svg",[]).run(["$templateCache",function(a){a.put("navigate-first.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7 6 v12 h2 v-12 h-2z M17.41 7.41L16 6l-6 6 6 6 1.41-1.41L12.83 12z"/></svg>')}]),b.module("navigate-last.svg",[]).run(["$templateCache",function(a){a.put("navigate-last.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M15 6 v12 h2 v-12 h-2z M8 6L6.59 7.41 11.17 12l-4.58 4.59L8 18l6-6z"/></svg>')}]),b.module("navigate-next.svg",[]).run(["$templateCache",function(a){a.put("navigate-next.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>')}]),b.module("md.data.table",["md.table.templates"]),b.module("md.data.table").directive("mdBody",d),b.module("md.data.table").directive("mdCell",e),b.module("md.data.table").directive("mdColumn",f),f.$inject=["$compile","$mdUtil"],b.module("md.data.table").decorator("$controller",g).factory("$mdEditDialog",h),g.$inject=["$delegate"],h.$inject=["$compile","$controller","$document","$mdUtil","$q","$rootScope","$templateCache","$templateRequest","$window"],b.module("md.data.table").directive("mdFoot",i),b.module("md.data.table").directive("mdHead",j),j.$inject=["$compile"],b.module("md.data.table").directive("mdRow",k),b.module("md.data.table").directive("mdSelect",l),l.$inject=["$compile","$parse"],b.module("md.data.table").directive("mdTable",n),b.module("md.data.table").directive("mdTablePagination",o),b.module("md.data.table").directive("mdTableProgress",p),b.module("md.data.table").directive("virtualPageSelect",q)}(window,angular); | ||
!function(a,b,c){"use strict";function d(){function a(a){a.addClass("md-body")}return{compile:a,restrict:"A"}}function e(){function a(a){var b=a.find("md-select");return b.length&&b.addClass("md-table-select").attr("md-container-class","md-table-select"),a.addClass("md-cell"),c}function b(){}function c(a,b,c,d){function e(){return i.$$columns[f()]}function f(){return Array.prototype.indexOf.call(b.parent().children(),b[0])}var g=b.find("md-select"),h=d.shift(),i=d.shift();c.ngClick&&b.addClass("md-clickable"),g.length&&(g.on("click",function(a){a.stopPropagation()}),b.addClass("md-clickable").on("click",function(a){a.stopPropagation(),g[0].click()})),h.getTable=i.getElement,a.$watch(e,function(a){a&&(a.numeric?b.addClass("md-numeric"):b.removeClass("md-numeric"))})}return{controller:b,compile:a,require:["mdCell","^^mdTable"],restrict:"A"}}function f(a,c){function d(a){return a.addClass("md-column"),e}function e(d,e,f,g){function h(){var c=b.element('<md-icon md-svg-icon="arrow-up.svg">');a(c.addClass("md-sort-icon").attr("ng-class","getDirection()"))(d),e.hasClass("md-numeric")?e.prepend(c):e.append(c)}function i(){Array.prototype.some.call(e.find("md-icon"),function(a){return a.classList.contains("md-sort-icon")&&e[0].removeChild(a)})}function j(){i(),e.removeClass("md-sort").off("click",o)}function k(){h(),e.addClass("md-sort").on("click",o)}function l(){return Array.prototype.indexOf.call(e.parent().children(),e[0])}function m(){return d.orderBy&&(q.order===d.orderBy||q.order==="-"+d.orderBy)}function n(){return""===f.mdNumeric||d.numeric}function o(){d.$applyAsync(function(){m()?q.order="md-asc"===d.getDirection()?"-"+d.orderBy:d.orderBy:q.order="md-asc"===d.getDirection()?d.orderBy:"-"+d.orderBy,b.isFunction(q.onReorder)&&c.nextTick(function(){q.onReorder(q.order)})})}function p(a,b){r.$$columns[a]=b,b.numeric?e.addClass("md-numeric"):e.removeClass("md-numeric")}var q=g.shift(),r=g.shift();d.getDirection=function(){return m()?"-"===q.order.charAt(0)?"md-desc":"md-asc":""===f.mdDesc||d.$eval(f.mdDesc)?"md-desc":"md-asc"},d.$watch(m,function(a){a?e.addClass("md-active"):e.removeClass("md-active")}),d.$watch(l,function(a){p(a,{numeric:n()})}),d.$watch(n,function(a){p(l(),{numeric:a})}),d.$watch("orderBy",function(a){a?k():j()})}return{compile:d,require:["^^mdHead","^^mdTable"],restrict:"A",scope:{numeric:"=?mdNumeric",orderBy:"@?mdOrderBy"}}}function g(a){return function(c,d,e,f){if(e&&"object"==typeof e){var g=a(c,d,!0,f);return b.extend(g.instance,e),g()}return a(c,d,e,f)}}function h(a,c,d,e,f,g,h,i,j){function k(c,d){var f,h=g.$new(),i=a(c)(h),j=e.createBackdrop(h,"md-edit-dialog-backdrop");return d.controller?f=m(d,h,{$element:i,$scope:h}):b.extend(h,d.scope),d.disableScroll&&l(i),v.prepend(j).append(i.addClass("md-whiteframe-1dp")),r(i,d.target),d.focusOnOpen&&q(i),d.clickOutsideToClose&&j.on("click",function(){i.remove()}),d.escToClose&&p(i),i.on("$destroy",function(){u=!1,j.remove()}),f}function l(a){var b=e.disableScrollAround(a,v);a.on("$destroy",function(){b()})}function m(a,d,e){return a.controller?(a.resolve&&b.extend(e,a.resolve),a.locals&&b.extend(e,a.locals),a.controllerAs?(d[a.controllerAs]={},a.bindToController?b.extend(d[a.controllerAs],a.scope):b.extend(d,a.scope)):b.extend(d,a.scope),a.bindToController?c(a.controller,e,d[a.controllerAs]):c(a.controller,e)):void 0}function n(a){return f(function(c,d){function e(a){d("Unexpected template value. Expected a string; received a "+a+".")}var f=a.template;if(f)return b.isString(f)?c(f):e(typeof f);if(a.templateUrl){if(f=h.get(a.templateUrl))return c(f);var g=function(a){return c(a)},j=function(){return d("Error retrieving template from URL.")};return i(a.templateUrl).then(g,j)}d("Template not provided.")})}function o(a){u=!1,console.error(a)}function p(a){var b=function(b){b.keyCode===t&&a.remove()};v.on("keyup",b),a.on("$destroy",function(){v.off("keyup",b)})}function q(a){e.nextTick(function(){var b=e.findFocusTarget(a);b&&b.focus()},!1)}function r(a,c){var d=b.element(c).controller("mdCell").getTable(),e=function(){return a.prop("clientHeight")},f=function(){return{width:i(),height:e()}},h=function(){var a=d.parent();return"MD-TABLE-CONTAINER"===a.prop("tagName")?a[0].getBoundingClientRect():d[0].getBoundingClientRect()},i=function(){return a.prop("clientWidth")},k=function(){var b=f(),d=c.getBoundingClientRect(),e=h();b.width>e.right-d.left?a.css("left",e.right-b.width+"px"):a.css("left",d.left+"px"),b.height>e.bottom-d.top?a.css("top",e.bottom-b.height+"px"):a.css("top",d.top+1+"px"),a.css("minWidth",d.width+"px")},l=g.$watch(i,k),m=g.$watch(e,k);j.addEventListener("resize",k),a.on("$destroy",function(){l(),m(),j.removeEventListener("resize",k)})}function s(a,c){function d(){var a='type="'+(c.type||"text")+'"';for(var b in c.validators)a+=" "+b+'="'+c.validators[b]+'"';return a}return{controller:["$element","$q","save","$scope",function(a,c,d,e){function f(){return e.editDialog.$invalid?c.reject():b.isFunction(d)?c.when(d(e.editDialog.input)):c.resolve()}this.dismiss=function(){a.remove()},this.getInput=function(){return e.editDialog.input},e.dismiss=this.dismiss,e.submit=function(){f().then(function(){e.dismiss()})}}],locals:{save:c.save},scope:{cancel:c.cancel||"Cancel",messages:c.messages,model:c.modelValue,ok:c.ok||"Save",placeholder:c.placeholder,title:c.title,size:a},template:'<md-edit-dialog><div layout="column" class="md-content"><div ng-if="size === \'large\'" class="md-title">{{title || \'Edit\'}}</div><form name="editDialog" layout="column" ng-submit="submit(model)"><md-input-container md-no-float><input name="input" ng-model="model" md-autofocus placeholder="{{placeholder}} "'+d()+'><div ng-messages="editDialog.input.$error"><div ng-repeat="(key, message) in messages" ng-message="{{key}}">{{message}}</div></div></md-input-container></form></div><div ng-if="size === \'large\'" layout="row" layout-align="end" class="md-actions"><md-button class="md-primary" ng-click="dismiss()">{{cancel}}</md-button><md-button class="md-primary" ng-click="submit()">{{ok}}</md-button></div></md-edit-dialog>'}}var t=27,u=!1,v=b.element(d.prop("body")),w={clickOutsideToClose:!0,disableScroll:!0,escToClose:!0,focusOnOpen:!0};return this.show=function(a){if(u)return f.reject();if(u=!0,a=b.extend({},w,a),!a.targetEvent)return o("options.targetEvent is required to align the dialog with the table cell.");if(!a.targetEvent.currentTarget.classList.contains("md-cell"))return o("The event target must be a table cell.");if(a.bindToController&&!a.controllerAs)return o("You must define options.controllerAs when options.bindToController is true.");a.target=a.targetEvent.currentTarget;var c=n(a),d=[c];for(var e in a.resolve)c=a.resolve[e],d.push(f.when(b.isFunction(c)?c():c));return c=f.all(d),c["catch"](o),c.then(function(b){var c=b.shift();for(var d in a.resolve)a.resolve[d]=b.shift();return k(c,a)})},this.small=function(a){return this.show(b.extend({},a,s("small",a)))}.bind(this),this.large=function(a){return this.show(b.extend({},a,s("large",a)))}.bind(this),this}function i(){function a(a){a.addClass("md-foot")}return{compile:a,restrict:"A"}}function j(a){function c(a){return a.addClass("md-head"),e}function d(){}function e(c,d,e,f){function g(){d.children().prepend('<th class="md-column md-checkbox-column">')}function h(){d.prop("lastElementChild").firstElementChild.appendChild(a(i())(c)[0])}function i(){return b.element("<md-checkbox>").attr({"aria-label":"Select All","ng-click":"toggleAll()","ng-checked":"allSelected()","ng-disabled":"!getSelectableRows().length"})}function j(){var a=d.prop("lastElementChild").firstElementChild;a.classList.contains("md-checkbox-column")&&b.element(a).empty()}function k(){return f.$$rowSelect}function l(a){return b.element(a).controller("mdSelect")}function m(){Array.prototype.some.call(d.find("th"),function(a){return a.classList.contains("md-checkbox-column")&&a.remove()})}var n=new Array(2);c.allSelected=function(){var a=c.getSelectableRows();return a.length&&a.every(function(a){return a.isSelected()})},c.getSelectableRows=function(){return f.getBodyRows().map(l).filter(function(a){return a&&!a.disabled})},c.selectAll=function(){f.getBodyRows().map(l).forEach(function(a){a&&!a.isSelected()&&a.select()})},c.toggleAll=function(){return c.allSelected()?c.unSelectAll():c.selectAll()},c.unSelectAll=function(){f.getBodyRows().map(l).forEach(function(a){a&&a.isSelected()&&a.deselect()})},c.$watchGroup([k,f.enableMultiSelect],function(a){a[0]!==n[0]?a[0]?(g(),a[1]&&h()):m():a[0]&&a[1]!==n[1]&&(a[1]?h():j()),b.copy(a,n)})}return{bindToController:!0,compile:c,controller:d,controllerAs:"$mdHead",require:"^^mdTable",restrict:"A",scope:{order:"=?mdOrder",onReorder:"=?mdOnReorder"}}}function k(){function a(a){return a.addClass("md-row"),c}function c(a,c,d,e){function f(){return e.$$rowSelect}function g(){return-1!==e.getBodyRows().indexOf(c[0])}function h(a){return c[0].contains(a[0])}if(g()){var i=b.element('<td class="md-cell">');a.$watch(f,function(a){return a&&!d.mdSelect?void(h(i)||c.prepend(i)):void(h(i)&&i.remove())})}}return{compile:a,require:"^^mdTable",restrict:"A"}}function l(a,c){function d(){}function e(d,e,f,g){function h(){return""===f.mdAutoSelect||o.autoSelect}function i(){var c=b.element("<md-checkbox>").attr({"aria-label":"Select Row","ng-click":"$mdSelect.toggle($event)","ng-checked":"$mdSelect.isSelected()","ng-disabled":"$mdSelect.disabled"});return b.element('<td class="md-cell md-checkbox-cell">').append(a(c)(d))}function j(){Array.prototype.some.call(e.children(),function(a){return a.classList.contains("md-checkbox-cell")&&e[0].removeChild(a)}),h()&&e.off("click",n)}function k(){e.prepend(i()),h()&&e.on("click",n)}function l(){return p.$$rowSelect}function m(a){return o.id?p.$$hash.has(o.id)?void(-1===a.indexOf(p.$$hash.get(o.id))&&p.$$hash.purge(o.id)):void(-1!==a.indexOf(o.model)&&p.$$hash.update(o.id,o.model)):void 0}function n(a){d.$applyAsync(function(){o.toggle(a)})}var o=g.shift(),p=g.shift(),q=c(f.mdSelectId);if(o.id=q(o.model),p.$$rowSelect&&o.id)if(p.$$hash.has(o.id)){var r=p.selected.indexOf(p.$$hash.get(o.id));-1===r?p.$$hash.purge(o.id):p.$$hash.equals(o.id,o.model)||(p.$$hash.update(o.id,o.model),p.selected.splice(r,1,o.model))}else p.selected.some(function(a,b){return q(a)===o.id?(p.$$hash.update(o.id,o.model),p.selected.splice(b,1,o.model),!0):void 0});o.isSelected=function(){return p.$$rowSelect?o.id?p.$$hash.has(o.id):-1!==p.selected.indexOf(o.model):!1},o.select=function(){o.disabled||(p.enableMultiSelect()?p.selected.push(o.model):p.selected.splice(0,p.selected.length,o.model),b.isFunction(o.onSelect)&&o.onSelect(o.model))},o.deselect=function(){o.disabled||(p.selected.splice(p.selected.indexOf(o.model),1),b.isFunction(o.onDeselect)&&o.onDeselect(o.model))},o.toggle=function(a){return a&&a.stopPropagation&&a.stopPropagation(),o.isSelected()?o.deselect():o.select()},d.$watch(l,function(a){a?k():j()}),d.$watch(h,function(a,b){a!==b&&(p.$$rowSelect&&a?e.on("click",n):e.off("click",n))}),d.$watch(o.isSelected,function(a){return a?e.addClass("md-selected"):e.removeClass("md-selected")}),d.$watch(p.enableMultiSelect,function(a){p.$$rowSelect&&!a&&p.selected.splice(1)}),p.registerModelChangeListener(m),e.on("$destroy",function(){p.removeModelChangeListener(m)})}return{bindToController:!0,controller:d,controllerAs:"$mdSelect",link:e,require:["mdSelect","^^mdTable"],restrict:"A",scope:{model:"=mdSelect",disabled:"=ngDisabled",onSelect:"=?mdOnSelect",onDeselect:"=?mdOnDeselect",autoSelect:"=mdAutoSelect"}}}function m(){var a={};this.equals=function(b,c){return a[b]===c},this.get=function(b){return a[b]},this.has=function(b){return a.hasOwnProperty(b)},this.purge=function(b){delete a[b]},this.update=function(b,c){a[b]=c}}function n(){function a(a,c){if(a.addClass("md-table"),c.hasOwnProperty("mdProgress")){var d=a.find("tbody")[0],e=b.element('<thead class="md-table-progress">');d&&a[0].insertBefore(e[0],d)}}function c(a,c,d,e){function f(){l.$$rowSelect=!0,k=e.$watchCollection("$mdTable.selected",function(a){o.forEach(function(b){b(a)})}),c.addClass("md-row-select")}function g(){l.$$rowSelect=!1,b.isFunction(k)&&k(),c.removeClass("md-row-select")}function h(){return n.length?void n[0]["finally"](function(){n.shift(),h()}):e.$applyAsync()}function i(){return""===a.mdRowSelect||l.rowSelect}function j(){return l.selected?b.isArray(l.selected)?!0:console.error("Row selection: Expected an array. Recived "+typeof l.selected+"."):console.error("Row selection: ngModel is not defined.")}var k,l=this,n=[],o=[];l.$$hash=new m,l.$$columns={},l.columnCount=function(){return l.getRows(c[0]).reduce(function(a,b){return b.cells.length>a?b.cells.length:a},0)},l.getRows=function(a){return Array.prototype.filter.call(a.rows,function(a){return!a.classList.contains("ng-leave")})},l.getBodyRows=function(){return Array.prototype.reduce.call(c.prop("tBodies"),function(a,b){return a.concat(l.getRows(b))},[])},l.getElement=function(){return c},l.getHeaderRows=function(){return l.getRows(c.prop("tHead"))},l.enableMultiSelect=function(){return""===a.multiple||e.$eval(a.multiple)},l.waitingOnPromise=function(){return!!n.length},l.queuePromise=function(a){a&&1===n.push(b.isArray(a)?d.all(a):d.when(a))&&h()},l.registerModelChangeListener=function(a){o.push(a)},l.removeModelChangeListener=function(a){var b=o.indexOf(a);-1!==b&&o.splice(b,1)},a.hasOwnProperty("mdProgress")&&e.$watch("$mdTable.progress",l.queuePromise),e.$watch(i,function(a){a&&j()?f():g()})}return c.$inject=["$attrs","$element","$q","$scope"],{bindToController:!0,compile:a,controller:c,controllerAs:"$mdTable",restrict:"A",scope:{progress:"=?mdProgress",selected:"=ngModel",rowSelect:"=mdRowSelect"}}}function o(){function a(a){a.addClass("md-table-pagination")}function c(a,c,d){function e(a){return!isNaN(a)&&!f(a)}function f(a){return 0===parseInt(a,10)}var g=this,h={page:"Page:",rowsPerPage:"Rows per page:",of:"of"};g.label=b.copy(h),g.disableNext=function(){return f(g.limit)||!g.hasNext()},g.first=function(){g.page=1,g.onPaginationChange()},g.hasNext=function(){return g.page*g.limit<g.total},g.hasPrevious=function(){return g.page>1},g.last=function(){g.page=g.pages(),g.onPaginationChange()},g.max=function(){return g.hasNext()?g.page*g.limit:g.total},g.min=function(){return f(g.total)?0:g.page*g.limit-g.limit+1},g.next=function(){g.page++,g.onPaginationChange()},g.onPaginationChange=function(){b.isFunction(g.onPaginate)&&c.nextTick(function(){g.onPaginate(g.page,g.limit)})},g.pages=function(){return e(g.total)?Math.ceil(g.total/(e(g.limit)?1:g.limit)):1},g.previous=function(){g.page--,g.onPaginationChange()},g.showBoundaryLinks=function(){return""===a.mdBoundaryLinks||g.boundaryLinks},g.showPageSelect=function(){return""===a.mdPageSelect||g.pageSelect},d.$watch("$pagination.limit",function(a,b){isNaN(a)||isNaN(b)||a===b||(g.page=Math.floor((g.page*b-b+a)/(f(a)?1:a)),g.onPaginationChange())}),a.$observe("mdLabel",function(a){b.extend(g.label,h,d.$eval(a))}),d.$watch("$pagination.total",function(a,b){isNaN(a)||a===b||g.page>g.pages()&&g.last()})}return c.$inject=["$attrs","$mdUtil","$scope"],{bindToController:{boundaryLinks:"=?mdBoundaryLinks",disabled:"=ngDisabled",limit:"=mdLimit",page:"=mdPage",pageSelect:"=?mdPageSelect",onPaginate:"=?mdOnPaginate",limitOptions:"=?mdLimitOptions",total:"@mdTotal"},compile:a,controller:c,controllerAs:"$pagination",restrict:"E",scope:{},templateUrl:"md-table-pagination.html"}}function p(){function a(a,b,c,d){a.columnCount=d.columnCount,a.deferred=d.waitingOnPromise}return{link:a,require:"^^mdTable",restrict:"C",scope:{},templateUrl:"md-table-progress.html"}}function q(){function a(a,b){function c(a,b){return Math.min(a,isFinite(b)&&d(b)?b:1)}function d(a){return a>0}function e(a){if(f.pages.length>a)return f.pages.splice(a);for(var b=f.pages.length;a>b;b++)f.pages.push(b+1)}var f=this,g=a.find("md-content");f.pages=[],g.on("scroll",function(){g.prop("clientHeight")+g.prop("scrollTop")>=g.prop("scrollHeight")&&b.$applyAsync(function(){e(c(f.pages.length+10,f.total))})}),b.$watch("$pageSelect.total",function(a){e(c(Math.max(f.pages.length,10),a))})}return a.$inject=["$element","$scope"],{bindToController:{total:"@"},controller:a,controllerAs:"$pageSelect"}}b.module("md.table.templates",["md-table-pagination.html","md-table-progress.html","arrow-up.svg","navigate-before.svg","navigate-first.svg","navigate-last.svg","navigate-next.svg"]),b.module("md-table-pagination.html",[]).run(["$templateCache",function(a){a.put("md-table-pagination.html",'<div class="page-select" ng-if="$pagination.showPageSelect()">\n <div class="label">{{$pagination.label.page}}</div>\n\n <md-select virtual-page-select total="{{$pagination.pages()}}" class="md-table-select" ng-model="$pagination.page" md-container-class="md-pagination-select" ng-change="$pagination.onPaginationChange()" ng-disabled="$pagination.disabled" aria-label="Page">\n <md-content>\n <md-option ng-repeat="page in $pageSelect.pages" ng-value="page">{{page}}</md-option>\n </md-content>\n </md-select>\n</div>\n\n<div class="limit-select" ng-if="$pagination.limitOptions">\n <div class="label">{{$pagination.label.rowsPerPage}}</div>\n\n <md-select class="md-table-select" ng-model="$pagination.limit" md-container-class="md-pagination-select" ng-disabled="$pagination.disabled" aria-label="Rows" placeholder="{{ $pagination.limitOptions[0] }}">\n <md-option ng-repeat="rows in $pagination.limitOptions" ng-value="rows">{{rows}}</md-option>\n </md-select>\n</div>\n\n<div class="buttons">\n <div class="label">{{$pagination.min()}} - {{$pagination.max()}} {{$pagination.label.of}} {{$pagination.total}}</div>\n\n <md-button class="md-icon-button" type="button" ng-if="$pagination.showBoundaryLinks()" ng-click="$pagination.first()" ng-disabled="$pagination.disabled || !$pagination.hasPrevious()" aria-label="First">\n <md-icon md-svg-icon="navigate-first.svg"></md-icon>\n </md-button>\n\n <md-button class="md-icon-button" type="button" ng-click="$pagination.previous()" ng-disabled="$pagination.disabled || !$pagination.hasPrevious()" aria-label="Previous">\n <md-icon md-svg-icon="navigate-before.svg"></md-icon>\n </md-button>\n\n <md-button class="md-icon-button" type="button" ng-click="$pagination.next()" ng-disabled="$pagination.disabled || $pagination.disableNext()" aria-label="Next">\n <md-icon md-svg-icon="navigate-next.svg"></md-icon>\n </md-button>\n\n <md-button class="md-icon-button" type="button" ng-if="$pagination.showBoundaryLinks()" ng-click="$pagination.last()" ng-disabled="$pagination.disabled || $pagination.disableNext()" aria-label="Last">\n <md-icon md-svg-icon="navigate-last.svg"></md-icon>\n </md-button>\n</div>')}]),b.module("md-table-progress.html",[]).run(["$templateCache",function(a){a.put("md-table-progress.html",'<tr>\n <th colspan="{{columnCount()}}">\n <md-progress-linear ng-show="deferred()" md-mode="indeterminate"></md-progress-linear>\n </th>\n</tr>')}]),b.module("arrow-up.svg",[]).run(["$templateCache",function(a){a.put("arrow-up.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg>')}]),b.module("navigate-before.svg",[]).run(["$templateCache",function(a){a.put("navigate-before.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>')}]),b.module("navigate-first.svg",[]).run(["$templateCache",function(a){a.put("navigate-first.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7 6 v12 h2 v-12 h-2z M17.41 7.41L16 6l-6 6 6 6 1.41-1.41L12.83 12z"/></svg>')}]),b.module("navigate-last.svg",[]).run(["$templateCache",function(a){a.put("navigate-last.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M15 6 v12 h2 v-12 h-2z M8 6L6.59 7.41 11.17 12l-4.58 4.59L8 18l6-6z"/></svg>')}]),b.module("navigate-next.svg",[]).run(["$templateCache",function(a){a.put("navigate-next.svg",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>')}]),b.module("md.data.table",["md.table.templates"]),b.module("md.data.table").directive("mdBody",d),b.module("md.data.table").directive("mdCell",e),b.module("md.data.table").directive("mdColumn",f),f.$inject=["$compile","$mdUtil"],b.module("md.data.table").decorator("$controller",g).factory("$mdEditDialog",h),g.$inject=["$delegate"],h.$inject=["$compile","$controller","$document","$mdUtil","$q","$rootScope","$templateCache","$templateRequest","$window"],b.module("md.data.table").directive("mdFoot",i),b.module("md.data.table").directive("mdHead",j),j.$inject=["$compile"],b.module("md.data.table").directive("mdRow",k),b.module("md.data.table").directive("mdSelect",l),l.$inject=["$compile","$parse"],b.module("md.data.table").directive("mdTable",n),b.module("md.data.table").directive("mdTablePagination",o),b.module("md.data.table").directive("mdTableProgress",p),b.module("md.data.table").directive("virtualPageSelect",q)}(window,angular); |
{ | ||
"name": "angular-material-data-table", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"description": "Material Design data table.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,8 +6,8 @@ 'use strict'; | ||
function mdSelect($compile, $parse) { | ||
// empty controller to bind scope properties to | ||
function Controller() { | ||
} | ||
function postLink(scope, element, attrs, ctrls) { | ||
@@ -17,9 +17,9 @@ var self = ctrls.shift(); | ||
var getId = $parse(attrs.mdSelectId); | ||
self.id = getId(self.model); | ||
if(self.id) { | ||
if(tableCtrl.$$rowSelect && self.id) { | ||
if(tableCtrl.$$hash.has(self.id)) { | ||
var index = tableCtrl.selected.indexOf(tableCtrl.$$hash.get(self.id)); | ||
// if the item is no longer selected remove it | ||
@@ -29,3 +29,3 @@ if(index === -1) { | ||
} | ||
// if the item is not a reference to the current model update the reference | ||
@@ -36,5 +36,5 @@ else if(!tableCtrl.$$hash.equals(self.id, self.model)) { | ||
} | ||
} else { | ||
// check if the item has been selected | ||
@@ -45,3 +45,3 @@ tableCtrl.selected.some(function (item, index) { | ||
tableCtrl.selected.splice(index, 1, self.model); | ||
return true; | ||
@@ -52,3 +52,3 @@ } | ||
} | ||
self.isSelected = function () { | ||
@@ -58,10 +58,10 @@ if(!tableCtrl.$$rowSelect) { | ||
} | ||
if(self.id) { | ||
return tableCtrl.$$hash.has(self.id); | ||
} | ||
return tableCtrl.selected.indexOf(self.model) !== -1; | ||
}; | ||
self.select = function () { | ||
@@ -71,3 +71,3 @@ if(self.disabled) { | ||
} | ||
if(tableCtrl.enableMultiSelect()) { | ||
@@ -78,3 +78,3 @@ tableCtrl.selected.push(self.model); | ||
} | ||
if(angular.isFunction(self.onSelect)) { | ||
@@ -84,3 +84,3 @@ self.onSelect(self.model); | ||
}; | ||
self.deselect = function () { | ||
@@ -90,5 +90,5 @@ if(self.disabled) { | ||
} | ||
tableCtrl.selected.splice(tableCtrl.selected.indexOf(self.model), 1); | ||
if(angular.isFunction(self.onDeselect)) { | ||
@@ -98,3 +98,3 @@ self.onDeselect(self.model); | ||
}; | ||
self.toggle = function (event) { | ||
@@ -104,10 +104,10 @@ if(event && event.stopPropagation) { | ||
} | ||
return self.isSelected() ? self.deselect() : self.select(); | ||
}; | ||
function autoSelect() { | ||
return attrs.mdAutoSelect === '' || self.autoSelect; | ||
} | ||
function createCheckbox() { | ||
@@ -120,6 +120,6 @@ var checkbox = angular.element('<md-checkbox>').attr({ | ||
}); | ||
return angular.element('<td class="md-cell md-checkbox-cell">').append($compile(checkbox)(scope)); | ||
} | ||
function disableSelection() { | ||
@@ -129,3 +129,3 @@ Array.prototype.some.call(element.children(), function (child) { | ||
}); | ||
if(autoSelect()) { | ||
@@ -135,6 +135,6 @@ element.off('click', toggle); | ||
} | ||
function enableSelection() { | ||
element.prepend(createCheckbox()); | ||
if(autoSelect()) { | ||
@@ -144,7 +144,7 @@ element.on('click', toggle); | ||
} | ||
function enableRowSelection() { | ||
return tableCtrl.$$rowSelect; | ||
} | ||
function onSelectChange(selected) { | ||
@@ -154,3 +154,3 @@ if(!self.id) { | ||
} | ||
if(tableCtrl.$$hash.has(self.id)) { | ||
@@ -161,6 +161,6 @@ // check if the item has been deselected | ||
} | ||
return; | ||
} | ||
// check if the item has been selected | ||
@@ -171,3 +171,3 @@ if(selected.indexOf(self.model) !== -1) { | ||
} | ||
function toggle(event) { | ||
@@ -178,3 +178,3 @@ scope.$applyAsync(function () { | ||
} | ||
scope.$watch(enableRowSelection, function (enable) { | ||
@@ -187,3 +187,3 @@ if(enable) { | ||
}); | ||
scope.$watch(autoSelect, function (newValue, oldValue) { | ||
@@ -193,3 +193,3 @@ if(newValue === oldValue) { | ||
} | ||
if(tableCtrl.$$rowSelect && newValue) { | ||
@@ -201,9 +201,9 @@ element.on('click', toggle); | ||
}); | ||
scope.$watch(self.isSelected, function (isSelected) { | ||
return isSelected ? element.addClass('md-selected') : element.removeClass('md-selected'); | ||
}); | ||
scope.$watch(tableCtrl.enableMultiSelect, function (multiple) { | ||
if(!multiple) { | ||
if(tableCtrl.$$rowSelect && !multiple) { | ||
// remove all but the first selected item | ||
@@ -213,5 +213,5 @@ tableCtrl.selected.splice(1); | ||
}); | ||
tableCtrl.registerModelChangeListener(onSelectChange); | ||
element.on('$destroy', function () { | ||
@@ -221,3 +221,3 @@ tableCtrl.removeModelChangeListener(onSelectChange); | ||
} | ||
return { | ||
@@ -224,0 +224,0 @@ bindToController: true, |
@@ -21,4 +21,8 @@ 'use strict'; | ||
function isPositive(number) { | ||
return !isNaN(number) && !isZero(number); | ||
} | ||
function isZero(number) { | ||
return number === 0 || number === '0'; | ||
return parseInt(number, 10) === 0; | ||
} | ||
@@ -70,3 +74,3 @@ | ||
self.pages = function () { | ||
return Math.ceil(self.total / (isZero(self.limit) ? 1 : self.limit)); | ||
return isPositive(self.total) ? Math.ceil(self.total / (isPositive(self.limit) ? 1 : self.limit)) : 1; | ||
}; | ||
@@ -88,3 +92,3 @@ | ||
$scope.$watch('$pagination.limit', function (newValue, oldValue) { | ||
if(newValue === oldValue) { | ||
if(isNaN(newValue) || isNaN(oldValue) || newValue === oldValue) { | ||
return; | ||
@@ -103,3 +107,3 @@ } | ||
$scope.$watch('$pagination.total', function (newValue, oldValue) { | ||
if(newValue === oldValue) { | ||
if(isNaN(newValue) || newValue === oldValue) { | ||
return; | ||
@@ -106,0 +110,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
178117
3136